Question: Additional information: (Actual task is in the attachment at the bottom) Solve Dfs.c: //DFSmazesolver #include #include #include #include #includeCell.h #includehelpers.h #includeMaze.h #includeStack.h boolsolve(Mazem){ //TODO:Completethisfunction //Feelfreetoaddhelperfunctions

Additional information: (Actual task is in the attachment at the bottom)

Solve Dfs.c:

//DFSmazesolver

#include

#include

#include

#include

#include"Cell.h"

#include"helpers.h"

#include"Maze.h"

#include"Stack.h"

boolsolve(Mazem){

//TODO:Completethisfunction

//Feelfreetoaddhelperfunctions

returnfalse;

}

----------------------------------------------------------------------------------------------------------------------

Helpers.h:

#ifndef HELPERS_H

#define HELPERS_H

#include

#include "Cell.h"

/**

* Allocatesandreturns a 2D matrix of booleans with the given number

* of rows and columns. All entries are initialised to false. It isthe

* user's responsibility to call `freeBoolMatrix` to free the matrix.

*/

bool **createBoolMatrix(int nRows, int nCols);

/**

* Frees the given boolean matrix.

*/

void freeBoolMatrix(bool **matrix);

/**

* Allocatesandreturnsa 2D matrix of Cells with the give number of

* rows and columns. All entries are initialised to (0, 0).Itisthe

* user's responsibility to call `freeCellMatrix` to free the matrix.

*/

Cell **createCellMatrix(int nRows, int nCols);

/**

* Frees the given Cell matrix.

*/

void freeCellMatrix(Cell **matrix);

#endif

----------------------------------------------------------------------------------------------------------------

Stack.h:

// Interface to the Stack ADT

#ifndef STACK_H

#define STACK_H

#include

#include

#include "Cell.h"

typedef Cell Item;

typedef struct stack *Stack;

/**

* Creates a new empty stack

* Complexity: O(1)

*/

Stack StackNew(void);

/**

* Frees all resources associated with the given stack

* Complexity: O(n)

*/

void StackFree(Stack s);

/**

* Adds an item to the top of the stack

* Complexity: O(1)

*/

void StackPush(Stack s, Item it);

/**

* Removes an item from the top of the stack and returns it

* Assumes that the stack is not empty

* Complexity: O(1)

*/

Item StackPop(Stack s);

/**

* Gets the item at the top of the stack without removing it

* Assumes that the stack is not empty

* Complexity: O(1)

*/

Item StackTop(Stack s);

/**

* Gets the size of the given stack

* Complexity: O(1)

*/

int StackSize(Stack s);

/**

* Returns true if the stack is empty, and false otherwise

* Complexity: O(1)

*/

bool StackIsEmpty(Stack s);

---------------------------------------------------------------------------------------------------------------------------------

Maze.h:

#ifndef MAZE_H

#define MAZE_H

#include

#include "Cell.h"

typedef struct maze *Maze;

/**

* Reads in a maze from the given file. The file must be formatted as

* follows:

*

*The first line must begin with two integers:

*1. The height of the maze (H)

*2. The width of the maze (W)

*

*The next `H` lines must contain an ASCII representation of the

*maze, with a # representing a wall cell and a space representing

*a path cell. Each of these lines should contain `W` of these

*characters - additional characters will be ignored.

*

*The next line must begin with two integers:

*1. The 0-indexed row number of the starting cell

*2. The 0-indexed column number of the starting cell

*Additionally, the starting cell must not be a wall cell.

*

*The next line must begin with two integers:

*1. The 0-indexed row number of the exit cell

*2. The 0-indexed column number of the exit cell

*Additionally, the exit cell must not be a wall cell.

*

*The rest of the file may contain anything, such as comments.

*

* Returns the maze if it was read successfully, or NULL otherwise.

*/

Maze MazeRead(FILE *fp);

/**

* Frees all resources associated with the given maze

*/

void MazeFree(Maze m);

/**

* Gets the height of the maze

-----------------------------------------------------------------------------------------------------------------------------------------------

Additional information: (Actual task is in the attachment at the bottom)Solve Dfs.c://DFSmazesolver#include#include#include#include #include"Cell.h"#include"helpers.h"#include"Maze.h" #include"Stack.h" boolsolve(Mazem){//TODO:Completethisfunction//Feelfreetoaddhelperfunctionsreturnfalse;}----------------------------------------------------------------------------------------------------------------------Helpers.h:#ifndef HELPERS_H#define HELPERS_H #include #include "Cell.h" /*** Allocatesandreturns a

I Task 2 Implement the solve() function in solveD-Fs . c which also tries to solve the given maze but instead uses the depth-first search algorithm. Use the iterative implementation of the algorithm (i.e., the version that uses a stack). When you think you are done, use the make command to recompile the program and then run . /solveD-Fs maze-fite. Here are some possible animations produced from . IsolveD'Fs mazes/smalll. txt: You should avoid creating small offshoots that don't get explored like in the following animation: This is not proper DFS behaviour and you may be penalised slightly if your code produces an animation like this. \f

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!