Given a 2-D array A[-20 .... 10, 8 ..... 16] where the starting location is 20. Consider that the memory space occupied by the array is 4 bytes and stored is row-major order. What is the location of A[4][16]?
A
920
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
820
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
630
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
720
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is B 820 Given : range : [-20 .... 10][8 ..... 16]
location : A[4][16]
No. of rows (m) = 10 - (-20) + 1 = 31
No. of columns (n) = 15 - 8 + 1 = 8
New range : [0 ... 30][0 .... 7]
New location : A[4 - (-20)][16 - 8]
of A[4][16] ⇒ A[24][8]
A[0][0] = 20