GATE Computer ScienceModerateGATE CS (PYQ pattern)

An undirected simple graph on 100 vertices is stored by keeping only the upper triangle (without the diagonal) of its adjacency matrix as a packed bit array. How many bytes are needed (rounding up to whole bytes), compared with a full 100 x 100 bit matrix?

  1. A. 632 bytes vs 1250 bytes
  2. B. 619 bytes vs 1250 bytes
  3. C. 1238 bytes vs 1250 bytes
  4. D. 619 bytes vs 10000 bytes

Correct answer: B. 619 bytes vs 1250 bytes

The strict upper triangle has 100*99/2 = 4950 bits = 619 bytes (4950/8 = 618.75). The full matrix has 10000 bits = 1250 bytes.

More Programming and Data Structures (GATE) questions

Exams that ask this topic