Question: Complete the BFS code to find the path in the maze in C++ //////////////// graph.cpp //////////////// #include graph.h #include graph::graph() { int vertex; cin >>
Complete the BFS code to find the path in the maze in C++
//////////////// graph.cpp ////////////////
#include "graph.h" #include
graph::graph() { int vertex; cin >> size; adjList.resize(size,NULL); for(int i = 0; i > vertex; while(vertex != -1) { adjList[i] = new vnode(vertex,adjList[i]); // insert at begining cin >> vertex; } } }
//////////////// graph.h //////////////// #ifndef GRPH #define GRPH
#include
using namespace std;
struct vnode { int v; // vertex vnode *next; vnode(int u, vnode *n) {v=u; next=n;} };
typedef vnode * vnodeptr;
class graph { public: graph(); // interactive constructor using cin
protected: int size; vector
#endif
//////////////// maze.cpp ////////////////
#include "maze.h" #include
using namespace std;
maze::maze():graph() { cin >> start; cin >> exit; }
void maze::dfs(vector
if(start == exit) return; stack
void maze::print_dfs_exitpath() { vector
// Complete the code for this function
}
void maze::print_bfs_exitpath() { vector void maze::printPath(int u,vector //////////////// maze.h //////////////// #include "graph.h" class maze:public graph { public: maze(); void dfs(vector //////////////// main.cpp //////////////// #include using namespace std; int main() { maze RatHaus; RatHaus.print_dfs_exitpath(); cout Example output for DFS. 
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
