Subsets, traced one call at a time

Each box in the tree is one call to backtrack. Moving down an edge means choosing a number. Coming back up means undoing that choice and trying the next one.

CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Recursion tree

Hover a subset in res to find its call

not called yet running now paused, waiting on a child call finished (subset saved) #k = position in res

Call stack

Top frame runs; the rest are paused

Variables

nums dim cells are outside this call's range (before start)

path one shared list, edited in place by every call

res

Keyboard: ← → step, Space play or pause. Try up to 5 numbers; the tree always has 2n calls, one per subset.