GATE / CS ARCHIVE

GATE CSE 1998 / QUESTION 2.14

Row-major array address

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

GATE 1998, Q2.14 2 marks · MCQ
Report issue

Arrays & Linked Lists

Question 2.14, GATE 1998: A[1…10][1…15] is stored in row-major order, uses one memory location per integer, and A[1][1] is at 100. Find address A[i][j].
Tap to enlarge
Your answer
Answer & solution

Answer: A: 15i+j+84 (no official key was published)

Before row i there are i−1 complete rows, each containing 15 entries, contributing 15(i−1) locations. Within row i, column j is j−1 locations beyond its start. Add the base:100+15(i−1)+(j−1)=15i+j+84. This is A. Check i=j=1 gives 100, and increasing j by 1 advances one location, whereas increasing i by 1 advances fifteen. Those checks distinguish row-major from column-major formulas.

Original paper, page 5