































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































































student[1]
student[0] student[2]
student[3]
marks[1]
marks[0] marks[2]
(0,0) (0,1) (0,2) (0,3) (0,4) (1,0) (1,1) (1,2) (1,3) (1,4) (2,0) (2,1) (2,2) (2,3) (2,4)
(0,0) (^) (1,0) (2,0) (0,1) (^) (1,1) (2,1) (0,2) (^) (1,2) (2,2) (0,3) (^) (1,3) (2,3) (0,4) (^) (1,4) (2,4)
Given: B = 100, W = 4, and LB = 0
A[0] = 100 + 4 * (0 – 0) = 100
Given:
B = 100, W = 4, and LB = 0 A[1] = 100 + 4 * (1 – 0) = 104 A[2] = 100 + 4 * (2 – 0) = 108 A[3] = 100 + 4 * (3 – 0) = 112 A[4] = 100 + 4 * (4 – 0) = 116 A[5] = 100 + 4 * (5 – 0) = 120
B = Base address/address of first element, i.e. A[LBR][LBC] I = Row subscript of element whose address is to be found J = Column subscript of element whose address is to be found W = Number of bytes used to store a single array element LBR = Lower limit of row/start row index of matrix, if not given assume 0 LBC = Lower limit of column/start column index of matrix, if not given assume 0 N = Number of column of the given matrix M = Number of row of the given matrix
[0] [1] [2] [3] [0] (^1 2 3 ) [1] (^5 6 7 ) [2] (^9 10 11 )
Row-major
Address of A[I][J] = B + W * ( N * ( I – LBR ) + ( J – LBC ))
Address of A[2][1] = B + W * (4 * (2 – 0) + (1 – 0))
M = 3 N = 4
Address of A[2][1] = B + W * (4 * (2 – 0) + (1 – 0))
Address of A[2][1] = B + W * (4 * (2 – 0) + (1 – 0))
Address of A[2][1] = B + W * (4 * (2 – 0) + (1 – 0))
Address of A[I][J] = B + W * ( N * ( I – LBR ) + ( J – LBC ))
Address of A[I][J] = B + W * ( N * ( I – LBR ) + ( J – LBC ))
Address of A[I][J] = B + W * ( N * ( I – LBR ) + ( J – LBC ))
the address of the first element is 49. Find the address of the element A[4][3] when the storage is row major. Address of A[I][J] = B + W * ( N * ( I – LBR ) + ( J – LBC ))
LBC = 0. Address of A[4][3] = 49 + 4 * (5 * (4 – 0) + (3 - 0)) = 49 + 4 * (23) = 49 + 92 = 141