Skills101
← All practice quizzes

Graphs Quiz

8 questions12 minPass: 60%+10 XP on first pass

Adjacency lists, BFS vs DFS, islands, topological sort, union-find and Dijkstra.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    Why do graph traversals need a "visited" set when tree traversals usually don't?

  2. Question 2

    Which algorithm finds the fewest steps between two nodes in an UNWEIGHTED graph?

  3. Question 3

    How many islands are in this grid? (1 = land, 0 = water, connected up/down/left/right)

    1 1 0 0
    1 0 0 1
    0 0 1 1
    0 0 0 0
    
  4. Question 4

    "Can you finish all courses given prerequisites?" is the same as asking whether the directed graph…

  5. Question 5

    In Kahn's algorithm (topological sort), which nodes enter the queue first?

  6. Question 6

    Union-Find's union(a, b) returns False when a and b are already connected. In "Redundant Connection" this tells you…

  7. Question 7

    Dijkstra's algorithm works correctly only when edge weights are…

  8. Question 8

    In BFS, when should a node be marked visited to avoid adding it to the queue many times?