ProgrammingHard

A bit-packed bitset of 10^9 bits needs how much memory?

  1. A. About 1 GB, one byte per bit
  2. B. About 1 MB, since bits are tiny
  3. C. About 125 MB, since 10^9 / 8 bytes is 1.25 x 10^8 bytes
  4. D. About 4 GB, one int per bit

Correct answer: C. About 125 MB, since 10^9 / 8 bytes is 1.25 x 10^8 bytes

A bitset uses one bit per value, so 10^9 bits are 1.25 x 10^8 bytes, which is about 125 MB.

More C Programming questions

Exams that ask this topic