ProgrammingHard

A bit array for flags of 10^9 items is held as one byte per item. What is the memory use, and is it fast enough in typical limits?

  1. A. About 1 GB, which is usually too much, so pack the flags into bits (about 125 MB)
  2. B. About 1 MB, which is always fine
  3. C. About 4 GB, which is fine with a fast disk
  4. D. About 8 bytes total, since bytes are shared

Correct answer: A. About 1 GB, which is usually too much, so pack the flags into bits (about 125 MB)

One byte per flag uses 10^9 bytes, about 1 GB. Packing eight flags per byte reduces it to 125 MB.

More C Programming questions

Exams that ask this topic