← All topics
Graphs Quiz: questions with answers
8 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Why do graph traversals need a "visited" set when tree traversals usually don't?
- Q2. Which algorithm finds the fewest steps between two nodes in an UNWEIGHTED graph?
- Q3. How many islands are in this grid? (1 = land, 0 = water, connected up/down/left/right) (code)
- Q4. "Can you finish all courses given prerequisites?" is the same as asking whether the directed graph…
- Q5. In Kahn's algorithm (topological sort), which nodes enter the queue first?
- Q6. Union-Find's union(a, b) returns False when a and b are already connected. In "Redundant Connection" this tells you…
- Q7. Dijkstra's algorithm works correctly only when edge weights are…
- Q8. In BFS, when should a node be marked visited to avoid adding it to the queue many times?