Recursion & DP medium time O(2ⁿ) space O(n)
Backtracking — All Subsets
For each element in turn you make one binary choice — leave it out (–) or take it. Every root-to-leaf path spells one subset, and n elements give 2ⁿ leaves. Backtracking simply means undoing a choice and trying the other branch.
For each element, branch twice: leave it out (–) on the left, take it on the right.
1 / 17
A fixed scene — scrub through it, or open the code.
Practice
Machine twin: /dsa-viz-v2/subsets-backtracking.json — the full deterministic run as structured data.