Question: ( 5 pts ) Use the depth - first search algorithm with the graph below and E is the starting node, DFS ( startV )
pts Use the depthfirst search algorithm with the graph below and is the starting node, DFSstartV
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 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
