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?
- A. 632 bytes vs 1250 bytes
- B. 619 bytes vs 1250 bytes
- C. 1238 bytes vs 1250 bytes
- 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.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- The 4 largest elements of the stream 14, 7, 22, 3, 18, 9, 30, 11, 25, 5, 17, 28, 2, 21 are found with a min-heap of size 4 holding the…
- A sorted array was rotated: [15, 18, 22, 25, 30, 2, 4, 7, 9, 11, 12, 14]. The standard rotated binary search (compare a[lo] <= a[mid] to…
- Two singly linked lists merge into a common tail: list X has 7 nodes before the merge point, list Y has 11 nodes before it, and the shared…
- A singly linked list 1 -> 2 -> ... -> 12 is modified by reversing the sublist from position 3 to position 9 (1-indexed, inclusive), and…
- Eight sorted lists of 100 keys each (800 distinct keys) are merged with the standard two-way merge, whose worst case for lists of sizes p…
- The number of nodes of a complete binary tree is found recursively: compute the leftmost-path height and the rightmost-path height of the…