awesome-everything RU
↑ Back to the climb

Algorithms from zero

Graphs: free-recall review

Crux Free-recall prompts across the graphs unit. Answer each in your own words first, then reveal the model answer and compare.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 13 min

Retrieval beats re-reading. For each prompt, say or write a full answer from memory before you open the model answer — the effort of recall is what makes the material stick.

Goal

Reconstruct the unit’s core mechanisms — representation tradeoffs, BFS vs DFS, topological sort, Dijkstra’s settle invariant, and union-find’s amortized bound — without looking back at the lessons.

Recall before you leave
  1. 01
    When do you choose an adjacency list over an adjacency matrix, and what does each cost?
  2. 02
    BFS and DFS both run in O(V + E). When does the order matter, and what does each give you?
  3. 03
    What is a topological order, when does it exist, and how do the two algorithms detect a cycle?
  4. 04
    State Dijkstra's settle invariant and explain exactly why it fails with a negative edge.
  5. 05
    Why is union-find's amortized cost O(alpha(n)) and not true O(1) or O(log n)?
  6. 06
    Connected components can be found with BFS/DFS or with union-find. When do you reach for each?
Recap

If you could reconstruct each answer from memory, you hold the unit’s spine: representation tradeoffs (list for sparse, matrix for dense or O(1) lookup), BFS for fewest-edge paths and DFS for depth and ordering, topological sort with built-in cycle detection, Dijkstra’s settle invariant and why non-negative weights are mandatory, and union-find’s amortized O(alpha(n)) for dynamic connectivity. The recurring lesson is to match the algorithm to the problem’s shape before coding.

Continue the climb ↑Graphs: code and bug reading
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.