Bitset
An 8-bit word as an array of bits: get, set, clear and toggle are one mask operation each.
Bit Manipulation: Set a bit that was 0
Set bit 2 of 178. 178 is 10110010 in binary. Bit 0 is on the left here, so each index is its bit number.
Cost
- Test
- O(1)
- Set
- O(1)
- And or xor
- O(n / w)
- Space
- O(n / w)
w is the machine word size.
Related
Leads to
Topics that need this one first.
Taught by the same lesson
Bit Manipulation covers these too, in the same run.