Recall & Review
beginner
What is the main idea behind generating subsets using bitmask?
Each subset corresponds to a binary number where each bit represents whether an element is included (1) or excluded (0) from the subset.
Click to reveal answer
beginner
How many subsets can be generated from a set of size n using bitmask?
There are 2^n subsets because each element can either be included or excluded independently.
Click to reveal answer
beginner
In bitmask subset generation, what does the bit at position i represent?
The bit at position i indicates whether the element at index i in the original set is included (1) or excluded (0) in the current subset.
Click to reveal answer
intermediate
Why is bitmask subset generation efficient for small sets?
Because it uses simple binary operations to generate all subsets without recursion, making it fast and easy to implement for sets with small n.
Click to reveal answer
beginner
What is the output of subsets generation using bitmask for the set [1, 2]?
The subsets are: [], [1], [2], [1, 2].
Click to reveal answer
How many subsets does a set with 3 elements have?
✗ Incorrect
A set with 3 elements has 2^3 = 8 subsets.
In bitmask subset generation, what does the bit value 0 mean for an element?
✗ Incorrect
Bit value 0 means the element is excluded from the subset.
Which operation is commonly used to check if the i-th bit is set in a bitmask?
✗ Incorrect
The bitwise AND with (1 << i) checks if the i-th bit is set.
What is the time complexity of generating all subsets using bitmask for a set of size n?
✗ Incorrect
Each of the 2^n subsets requires checking up to n bits, so O(n * 2^n).
Which of the following is NOT a subset of [1, 2, 3]?
✗ Incorrect
[4] is not a subset because 4 is not in the original set.
Explain how bitmasking helps in generating all subsets of a set.
Think about how binary numbers can represent choices for each element.
You got /4 concepts.
Describe the steps to generate subsets using bitmask for the set [a, b, c].
Visualize binary numbers from 000 to 111.
You got /5 concepts.