Mental Model
Each subset can be represented by a series of on/off switches, where each switch decides if an element is included or not.
Analogy: Imagine you have a row of light switches, each controlling a lamp. Turning a switch on means including that lamp in the room's lighting; off means excluding it. Every combination of on/off switches creates a unique lighting setup, just like every combination of elements forms a unique subset.
Set: [1, 2, 3] Bitmask positions: 2 1 0 Example bitmask: 101 Subset: includes elements at positions with 1 -> 1 and 3 [1] [2] [3] ↑ ↑ ↑ 2^2 2^1 2^0 Bitmask 101 means: include 1st and 3rd elements, exclude 2nd.
