AlgoScope

Subset Enumeration

Counting from 0 to 2^n - 1 enumerates every subset. sub = (sub - 1) & mask enumerates submasks.

Bit manipulation, technique, intermediate
Mask 0, binary 000, is the subset { }.507192
Mask 0, binary 000, is the subset { }.507192

Bitmask: Every subset of three

Decision, step 2 of 10

mask 0 = 000: the subset { }. All bits off is the empty set.

How bitmask works

Cost

Best
O(2^n)
Average
O(2^n)
Worst
O(2^n)
Space
O(1)

Taught by the same lesson

Bitmask covers these too, in the same run.