Computer Science I / Graph Algorithms and Traversal
Practice question · Select all that apply

Select every true statement about graph traversal.

Hints
  1. One option swaps the data structures of the two traversals.
  2. DFS uses a stack, not a queue.
Show the answer
  • A. A traversal without a visited set can loop forever on a cyclic graph
  • B. BFS finds the fewest-edge path from the start in an unweighted graph
  • C. Dijkstra's algorithm needs a priority queue
  • E. BFS and DFS both run in O(V + E)
Why

Both traversals are O(V + E); BFS gives shortest unweighted paths; Dijkstra uses a priority queue; and the visited set prevents infinite loops. 'DFS uses a queue' is false. DFS uses a stack.

Read the lesson: Graph Algorithms and Traversal →

Practise Graph Algorithms and Traversal

The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Graph Algorithms and Traversal