Question: Given the following DFS algorithm and the graph. Assume E is the starting vertex, which vertices are in visitedSet after the first iteration of the
Given the following DFS algorithm and the graph. Assume E is the starting vertex, which vertices are in visitedSet after the first iteration of the while loop?
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
E
E C B D A
C B D
E C B D
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
