awesome-everything RU
↑ Back to the climb

Algorithms from zero

Recursion and backtracking: multiple-choice review

Crux Multiple-choice synthesis across the recursion unit: base/recursive case, call stack depth, recursion-tree complexity, the backtracking template, and pruning.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 13 min

Six questions that cut across the whole unit. Each one is a decision you make when you actually write recursive code, not a definition to recite, but a judgement about correctness, cost, or which fix is right.

Goal

Confirm you can connect the four ideas the unit built: a base case and a shrinking recursive case make recursion terminate, the call stack sets space, the recursion tree sets time, and backtracking with pruning turns brute force into something practical.

Quiz

A recursive function has a base case but still overflows the stack on every input, including tiny ones. What is the most likely cause?

Quiz

factorial(n) and naive fibonacci(n) both recurse to depth n. Why is factorial fine for large n while fibonacci is not?

Quiz

A recursive function has branching factor b = 3 and depth d = 12, doing O(1) work per call. Roughly how many calls does it make, and what does that tell you?

Quiz

In the choose-explore-undo backtracking template, what breaks if you omit the undo step (push to current but never pop)?

Quiz

Subsets, permutations, and combinations all use the same backtracking template. What actually distinguishes them?

Quiz

A correct recursive tree-walk works in tests, but a colleague says it must be rewritten iteratively before production. When is that warranted?

Recap

The unit’s through-line is one chain: a base case plus a shrinking recursive case make recursion terminate; the call stack makes depth cost O(depth) in space; the recursion tree makes total work the branching factor raised to the depth in time; and backtracking applies that recursive skeleton (choose, explore, undo) with pruning to skip doomed branches. Get the base case and progress right first, then read time from the tree and space from the stack.

Continue the climb ↑Recursion and backtracking: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.