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
-----------------------------------------------------------------------------------------------------------------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started