Question: ( 5 pts ) Use the depth - first search algorithm with the graph below and E is the starting node, DFS ( startV )

(5 pts) Use the depth-first search algorithm with the graph below and E is the starting node, DFS(startV){
Push startV to stack
while ( stack is not empty ){
currentV = Pop stack
if ( currentV is not in visitedSet ){
"Visit" currentV
Add currentV to visitedSet
for each vertex adjV adjacent to currentV
Push adjV to stack
}
}
}
After the 1st iteration of the while loop, the stack has: C, D (top of the stack is C).
Which vertices are in the stack after the second iteration of the while loop?
Note: the first node in your answer should be the node at the top of the stack.
( 5 pts ) Use the depth - first search algorithm

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