Practice Discrete Math

Algorithms / Subsets Combinations Search

Least You Need to Know: Subsets, Combinations, and Choose/Skip Search

Subset and combination search usually depends on a **choose/skip** structure. The important distinction is that order does not matter, so the recursion should move forward through candidates instead of revisiting earlier positions.

The least you need to know

Key notation

include / exclude choose the current item or skip it
start index first candidate allowed in this recursive call
combination an unordered selection of items

Tiny worked example

  • To list size-2 combinations from `[a,b,c]`, begin at index `0`.
  • Choose `a`, recurse on later positions, and pair it with `b` and `c`.
  • Then backtrack, skip `a`, and continue from `b`.
  • Because recursion only moves forward, `{a,b}` and `{b,a}` are not both generated.

Common mistakes

How to recognize this kind of problem

Start practice