MENU
Question -

Each element of the array A[8][6] is stored using 4 bytes of memory. If the element A[2][4] is stored at location 936, find the address of A[5][1]. Assume that the array is stored in Row Major.



Answer -

nr=8 nc=6 size = 4 bytes
A[2][4] = 936 A[5][1] = ?
Formula for row-major
A[i][j] = BA + size * ((i – sr) * nc + (j – sc))
A[5][1] = A[2][4] + 4 * ((5 – 2) * 6 + (1 – 4))
= 936 + 4* ((3) *6-3)
= 936 + 4 * 15
= 936 + 60
A[5][l] = 996

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×