InterviewSolution
Saved Bookmarks
| 1. |
An array A[50][30] is stored along the row in the memory with each element requiring 4 bytes of storage. If the element A[10][15] is stored at 21500, then find out the base address of the array and the memory address of element stored at location A[30][25]? |
|
Answer» Row-major Formula:- A[I][J]= B+ W*((I-Lr)*Nc + (J-Lc)) Nr=50, Nc=30, B=?, W=4, Lr=0, Lc=0, A(10,15)=21500 A[10][15]= B + 4*((10-0)*30 + (15-0)) 21500= B + 4*(300+15) 21500=B + 4*315 B=21500 – 1260 B=20240 A[30][25] = 20240 + 4*((30-0)*30 + (25-0)) A[30][25] = 20240 + 4*(900+25) A[30][25] = 20240 + 4*925 A[30][25] = 23940 |
|