Slideshow

Monday 25 February 2013



257. (i) what is meant by the terms 'row-major order' and 'column-major order'? 
(ii) Can the size of an array be declared at runtime? 
(iii) The array DATA [10, 15] is stored in memory in 'row - major order'.
If base address is 200 and element size is 1. Calculate the address of element
DATA [7, 12]. 

Ans: (i) Storing the array column by column is known as column-major order and
storing the array row by row is known as row-major-order. The particular order used
depends upon the programming language, not the user. For example consider array
A (3,4) and how this array will be stored in memory in both the cases is shown
below

(ii) No, the size of an array can't be declared at run time, we always need to
mention the dimensions of an array at the time of writing program i.e before run time
(iii) Base address=200
Element Size=l
Address of element DATA [7,12]
= 200+[(7-l)*15+(12-l)]*l
= 200+[6*15+11]
= 200+[90+11]=301
Address of DATA [7,12]=301

No comments:

Post a Comment