1.

A matrix A[m][m] is stored in the memory with each element requiring 4 bytes of storage. If the base address at A[1][1] is 1,500 and the address of A[4][5] is 1,608, determine the order of the matrix when it is stored in Column Major Wise.

Answer»

Formula for finding out address of A[J] [K] element is column-major order of Matrix (MXN) order.

LOC (A[J] [K]) = Base (A) + w (M(K– 1) + (J–1))

Given : M = N = m, w = 4 bytes

Bass address = 1500

address of A[4] [5] = 1608

LOC (A [4] [5]) = 1500 + 4(m (5 – 1) + (4 – 1))

1608 = 1500 + 4(4 m + 3)

1608 – 1500 = 16 m + 12

16 m = 108 – 12 = 96

m = 6

Therefore,

Order of the matrix is (6 × 6)



Discussion

No Comment Found

Related InterviewSolutions