ProgrammingHard
A bit-packed bitset of 10^9 bits needs how much memory?
- A. About 1 GB, one byte per bit
- B. About 1 MB, since bits are tiny
- C. About 125 MB, since 10^9 / 8 bytes is 1.25 x 10^8 bytes
- 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
- Which loop is correct and fast enough to find the largest element of an array of 10^7 ints, reading each value once?
- A program must answer 10^6 queries 'is x present in the set S?' where S has 10^6 values fixed in advance. Which preprocessing and query…
- How many times does a body run in for (int i = 2; i < 100; i = i)?
- Which change makes the loop for (int i = 0; i < strlen(s); i++) run in linear time?
- A 2D grid of 2000 x 2000 cells is searched by a BFS that visits each cell once. About how many cell visits happen?
- A program finds the number of pairs (i, j) with i < j among n = 10^5 elements by a nested loop. How many pair checks happen?