Using values 1,2,3: choose two; arrange two; or reuse values to total 4.
Decision: When is [2,1] a new answer after [1,2]? What information determines the next legal choice?
1 / 11
Letter Combinations of a Phone Number — predict before coding
This is a Cartesian product, not a membership search. Each digit fixes a position and supplies its allowed letters; every full tuple is an answer, so output size is an unavoidable cost.
Decision: A keypad expansion has finished the prefix "t" for digits "87". Complete the four second-letter outputs, then explain exactly which buffer state must be restored before the first letter changes to "u".
2 / 11
Combinations — predict before coding
A start index breaks permutation symmetry. Once a number is chosen, later choices must be larger; [1,3] is generated once and never again as [3,1].
Decision: For n=6, k=3, prefix [2] leaves how many completions? Prefix [5] has the same length; why can it be pruned immediately? Identify the information that path length alone omits.
3 / 11
Permutations — predict before coding
Positions matter here, unlike combinations. The used array tracks which input identities are already present in the current arrangement, so the next choice ranges over every unused index.
Decision: A branch has emitted [8,1,5] for input [8,1,5]. After undoing its last two choices, it starts [8,5]. Which used flags and next value are correct? Why must the emitted row remain unchanged?
4 / 11
Combination Sum — predict before coding
Positive reusable candidates turn the search into a nondecreasing sequence of choices. Sorting lets the first value above the remaining target stop the whole loop, not just one branch.
Decision: Candidates are [3,5] and target is 11. A branch begins with 5 and has remaining total 6. Why must that branch not append 3, even though [5,3,3] sums correctly? Where is the answer generated?
5 / 11
Generate Parentheses — predict before coding
Validity can be enforced on prefixes. An opening is allowed until n are used; a closing is allowed only when it matches an already unmatched opening.
Decision: For n=3 pairs, a proposed closing rule is “append ) when closeUsed<=openUsed.” Construct the shortest nonempty balanced prefix from which this rule makes an invalid next prefix. Which inequality fixes it?
6 / 11
N-Queens II — predict before coding
Placing exactly one queen per row removes one dimension of choice. Columns and the two diagonal identifiers summarize every conflict with earlier rows.
Decision: On a 4-by-4 board, earlier queens are (0,0) and (1,2). Show why row 2 has no legal column. Does that failure mean row 0 must immediately move, or is there still another branch to explore first?
7 / 11
Word Search — predict before coding
The same board cell may participate in different candidate paths, but not twice in one path. Visited state therefore belongs to one recursive branch and must be restored even when that branch succeeds.
Decision: On the one-row board ABA, can the word ABA be found? A learner stores visited letter values instead of visited cell positions. What valid step would that reject, and does the board support ABAA?
8 / 11
Word Search — is the cache key complete?
Board AAA / ABA; word BAAAA; start B=(1,1).
Both prefixes reach A=(0,0) at word index 2:
(1,1)->(0,1)->(0,0)
(1,1)->(1,0)->(0,0)
Decision: Why may a cached failure for the first prefix not reject the second?
9 / 11
Change the spacing rule
Choose three nonconsecutive days from days 1..6.
Derive the next-start rule. List all answers. Give a prune that uses the changed spacing.
10 / 11
Reconstruct and transfer
Reconstruct the branch state, decreasing measure, prune proof, restoration, and output-copy point.
Include output length in the complexity.
11 / 11
←/→ or click edges to navigate · ? help · N notes · F fullscreen