AlgoViz

Subsets

medium 22 min

Generating every subset is the first backtracking pattern most interviews ask for, and there are four standard ways to write it: take-or-skip recursion, a start-index loop, iterative cascading and bitmask counting.

Check yourself

One question at a time. Each answer explains why.

Question 1 of 10

Score 0
conceptual

What is the time complexity of generating all subsets of n elements?

Pick an answer to see why.

Flashcards

Say your answer, then reveal it.

Card 1 of 12

Recall

How many subsets do {1, 2, 3} and a 4-element set have?

Say your answer, then reveal it.

These cards come back in Today, just before you would forget them.