GATE / CS ARCHIVE

GATE CSE 1994 / QUESTION 1.11

Packing a lower triangular matrix

Data Structures · Arrays & Linked Lists · Full GATE CSE 1994 paper

GATE 1994, Q1.11 MCQ
Report issue

Arrays & Linked Lists

Question 1.11, GATE 1994: Rows of a lower triangular n×n matrix, including their diagonal, are stored consecutively. With one-based indices, where is entry (i,j), j≤i?
Tap to enlarge
Your answer
Answer & solution

Answer: C: i(i−1)/2+j (no official key was published)

Before row i, the stored rows have lengths 1,2,…,i−1, totaling i(i−1)/2 entries. Entry j in the next row is j positions beyond that prefix under one-based indexing. Therefore its packed index is i(i−1)/2+j. A zero-based packed offset would subtract one from this result. The formula stores every position in the lower triangle, even if a particular value happens to be zero; omitting actual zeros would require additional sparse-matrix metadata.

Original paper, page 2