Skip to content
DSA Visualizerpreview

Subsets (include or skip)

For each value, branch twice: take it or skip it. Every leaf of the tree is one subset.

O(n · 2ⁿ) time · O(n) recursion depth space

Values1, 2, 3

Start with nothing chosen. At each level decide: take 1 or skip it?

Decision tree for 1,2,3: 1 calls so far; subsets found: none.
  1. go(0): cur = {}
  • compare
  • swap or write
  • settled

1 / 16

Speed

Space play · ← → step · Home End jump · drag the strip to scrub