🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Graphs Quiz: questions with answers

8 questions, each with the answer and a short explanation.

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