Why is the traversal of a graph different from a tree?

a. There can be a loop in a graph so we must maintain a visited flag for every vertex
b. DFS of a graph uses stack, but in-order traversal of a tree is recursive
c. BFS of a graph uses queue, but a time efficient BFS of a tree is recursive
d. All of the above

a. There can be a loop in a graph so we must maintain a visited flag for every vertex
To avoid running into a never-ending loop, we use a Boolean array of visited vertices.

Computer Science & Information Technology

You might also like to view...

Sub procedures are used to store VBA procedures that can be referenced or called by other procedures or events in a database

Indicate whether the statement is true or false

Computer Science & Information Technology

How can you add a gradient fill to a shape?

What will be an ideal response?

Computer Science & Information Technology