Step 1: Start with empty subset [] at index 0
[] ↑ (index 0)
Why: We begin with no elements chosen
Step 2: Choose element 1, subset becomes [1], move to index 1
[1] ↑ (index 1)
Why: Try including first element
Step 3: Choose element 2, subset becomes [1, 2], move to index 2 (end)
[1, 2] ↑ (index 2)
Why: Try including second element
Step 4: Reached end, record subset [1, 2], backtrack to index 1
[1, 2] (recorded), back to [1] ↑ (index 1)
Why: Save current subset and try skipping element 2
Step 5: Skip element 2, subset stays [1], move to index 2 (end)
[1] ↑ (index 2)
Why: Try skipping second element
Step 6: Reached end, record subset [1], backtrack to index 0
[1] (recorded), back to [] ↑ (index 0)
Why: Save current subset and try skipping element 1
Step 7: Skip element 1, subset stays [], move to index 1
[] ↑ (index 1)
Why: Try skipping first element
Step 8: Choose element 2, subset becomes [2], move to index 2 (end)
[2] ↑ (index 2)
Why: Try including second element after skipping first
Step 9: Reached end, record subset [2], backtrack to index 1
[2] (recorded), back to [] ↑ (index 1)
Why: Save current subset and try skipping element 2
Step 10: Skip element 2, subset stays [], move to index 2 (end)
[] ↑ (index 2)
Why: Try skipping second element
Step 11: Reached end, record subset [], backtrack complete
[] (recorded)
Why: Save empty subset, all choices tried
Result: All subsets recorded: []
[1]
[1, 2]
[2]