Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions