← Graphs Quiz: all 8 questions
Graphs Quiz · Question 1 of 8
Why do graph traversals need a "visited" set when tree traversals usually don't?
Why do graph traversals need a "visited" set when tree traversals usually don't?
- A.Graphs can contain cycles, so without it you could loop forever
- B.Graphs always have more nodes
- C.Visited sets make BFS faster than DFS
- D.Trees can't be traversed with DFS
Answer & explanation
Correct answer: Graphs can contain cycles, so without it you could loop forever
Trees have no cycles; graphs may, so you must remember where you've been.
Can you get the rest right without peeking?
Take the timed Graphs Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →