in Programming in C edited by
2,588 views
0 votes
0 votes
In a lower triangular matrices (size 15 x 15) representation of compact single
dimensional array, non-zero elements (i.e. elements of the lower triangle) of each row are stored one after another, starting from the first row. Assume each integer take 1B. The array stored in row major order and first element of array is stored at location 1000, then the address of element a[10] [6] is______ B.

[Note: Only lower triangular elements of the matrix are stored in contiguous array]
in Programming in C edited by
by
2.6k views

4 Comments

total no of element crossed in the case of row major order is (i*(i+1)/2)+j
so total element are (5*11)+6  = 61
then the address will be 1000+(61*1) which is 1061
1
1
This is considering that array indexing starts from a[0][0]. Should not it be mentioned in the question or do we consider it by default?
0
0

@Jean

Yes you are right.They have to mention

Look for the answer

0
0

1 Answer

5 votes
5 votes

$a[1....15][1....15]$

$BA=1000$

$Size\ of\ element=1\ B$

$Loc[10][6]$

$\\ =1000+\left \{\underbrace {10-1=9}+(6-1) \right \}\times 1B$

                    $Natural\ \#\ sum\\ of\ 9\ rows$

$=1000+\left \{ \dfrac{9\times 10}{2}\ +\ 5 \right \}\times 1B$

$=1000+\left \{ 45+5 \right \}\times 1B$

$=1050B$


$a[0....14][0....14]$

$BA=1000$

$Size\ of\ element=1\ B$

$Loc[10][6]$

$\\ =1000+\left \{\underbrace {10-0=10}+(6-0) \right \}\times 1B$

                    $Natural\ \#\ sum\\ of\ 10\ rows$

$=1000+\left \{ \dfrac{10\times 11}{2}\ +\ 6 \right \}\times 1B$

$=1000+\left \{ 55+6 \right \}\times 1B$

$=1061B$

Related questions