Math Fundamentals18 sections · 814 units
Open in Course

Subsets - Include or Exclude

Decision tree approach

For each element, you have two choices: include it or exclude it. This creates a binary decision tree with 2n2^n leaves (one for each subset).

You can use the same backtracking pattern from combinations. At each recursive call, you add the current combination (no matter the size) to results, then try adding each remaining number.

Unlike combinations where you wait until size equals kk, here you record every state. The empty subset happens when you start (before adding any elements).