Question: please help me with the following question. the two functions dfs and bfs are explained as to the context the refer to in the actual

please help me with the following question. the two functions dfs and bfs are explained as to the context the refer to in the actual question. thank you!
QUESTION:
What is not specified in the functions dfs() and bfs() is what to do when you visit each node. Modify the two functions to accept an input parameter that accepts a function with the prototype:
void visit(T node) What this function does is left up to the person using your classes. You will need to call the function at the correct point in your code.
void dfs(Graph &g, T &startNode) : Do a depth-first traversal of the graph g, starting from node startNode. You may either print the contents of each node or implement the extra credit portion of the assignment.
void bfs(Graph &g, T &startNode) : Do breath-first traversal of the graph g, starting from node startNode. You may either print the contents of each node or implement the extra credit portion of the assignment

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 Databases Questions!