retagged by
1,187 views
1 votes
1 votes
Given a 2D array A[40….95, 40...95] in lower triangular representation, size of each element is 1 Byte

Array implemented in row major order, base address is 1000

Address of A[66][50] ?
retagged by

2 Answers

2 votes
2 votes

Given: 2D array A[40….95, 40...95]

size of element= 1 Byte, Row Major Order(RMO), Base Address(BA)= 1000, Lower Triangular Matrix

In general, 2D array A[LB1….UB1, LB2...UB2]  // LB: Lower Bound and UB: Upper Bound 

Address of A[i][j]= BA + [ (i-LB1) Natural Number Sum(NNS) + (j-LB2)]  * size of element  // (i-LB1) Natural no. sum because its lower triangular matrix with

RMO, first row will contain only 1 element, second row 2, 3rd row 3 elements and so on... 

Now, Address of A[66][50]= BA+ [(66-40)NNS +(50-40)] * Size of element

= 1000+ [ (26(26+1)/2) + 10] *1

= 1000+[351+10] =1361

edited by

Related questions

2 votes
2 votes
0 answers
3
1 votes
1 votes
0 answers
4