in DS edited by
1,170 views
1 vote
1 vote

https://gateoverflow.in/32836/location-of-element-using-row-major-order
A[5.....15,-8.....8] is A[11][17] and we are supposed to find A[8][5]  - Row Major Order Base Address:800, each element occupies 4 memory cells, then this is my analysis please let me know where im going wrong

A[11][17], we need to find A[8][5] in row major, this means 7 rows have been traversed already with each row containing 17 elements
=>(7*17)*4 = 476

Now we are in the 8th row we need to go to column 5 => 5*4=20

476+20=496

496+BaseAddress=496+800=1296

This question is already asked multiple times before, but i have an issue understanding something, the answer is no where close to mine and i know by application for formula, we can arrive at the answer, but i need to understand what im doing wrong here
Thanks

in DS edited by
by
1.2k views

1 Answer

1 vote
1 vote
Best answer
here rows starting from 5 not from 0 or 1.so from 5 to reach 8 we have to cross only 3 rows (5,6,7) with 17 elements in each row.after crossing 51 elements now we are in 8th row .in 8th row we want to go from -8 to 5 only.not cross 5.so 13 elements in 8th row.

so total elements crossed by us are 51+13=64 and each of size 4 so 64*4=256.now add base-address(800) +256 =1056
selected by

Related questions