Consider a two dimensional array A[20][10]. Assume 4 words per memory cell,…
2025
Consider a two dimensional array A[20][10]. Assume 4 words per memory cell, the base address of array A is 100, elements are stored in row-major order and first element is A[0][0]. What is the address of A[11][5] ?
- A.
560
- B.
460
- C.
570
- D.
575
Attempted by 4 students.
Show answer & explanation
Correct answer: A
Concept: For a two-dimensional array stored in row-major order, the address of an element A[i][j] is Address = Base + ((i × number of columns) + j) × word size, where the base address is the location of A[0][0] and each element occupies a fixed number of memory words.
Read off the given values: base address = 100, number of columns = 10, word size = 4 words per element, and the target indices i = 11, j = 5.
Combine the two indices into a single row-major element offset: (11 × 10) + 5 = 115.
Scale the element offset by the word size to get the offset in memory words: 115 × 4 = 460.
Add the base address to place this offset in actual memory: 100 + 460 = 560.
Cross-check: the address of A[11][0] is Base + (11 × 10 × 4) = 100 + 440 = 540. Element A[11][5] then lies 5 elements further along that row: 540 + (5 × 4) = 540 + 20 = 560 — the same result, confirming the address.
Address of A[11][5] = 560.