In a MAL program, a two-dimensional arrayTable of type integer with 7 rows and 7
ID: 3615778 • Letter: I
Question
In a MAL program, a two-dimensional arrayTable of type integer with 7 rows and 7 columnsis
stored in column majororder. Theaddress of the element Table[6][1]is 252(decimal). Find
thestarting address of the array. Your answer must be indecimal.
Explanation / Answer
please rate - thanks given matrix n rows m columns stored column wise need address of location matrix (i,j) where i is the row j is thecolumn assuming all indices start with a1. and 1 byte perlocation if an element is in column 1, there are 0 complete columns storedbefore it. if an element is in column 2, there are 1 complete columns storedbefore it. etc so if an element is in any column j there are j-1 columns storedbefore it. each of those complete columns has n elements in it (1 element perrow) so there are (j-1)n elements in complete rows, plus if we arelooking for element i in the column it is at location (j-1)n + i. so you are given an (7,7) matrix n=7, m=7 you are given i=6, j=1 so it is the (1-1)7 + 6 element = 6thelement it is at location 252 so (5,1) is at 251 (4,1) is at 250 (3,1) at 249 (2,1) at 248 (1,1) at 247 if indices start with 0, and >1 byte per location this formulahas to be adjusted--but this should get you started assuming all indices start with a0. and 1 byte perlocation if an element is in column 1, there are 1 complete columns storedbefore it. if an element is in column 2, there are 2 complete columns storedbefore it. etc so if an element is in any column j there are j columns storedbefore it. each of those complete columns has n elements in it (1 element perrow) so there are (j)n elements in complete rows, plus if we are lookingfor element i in the column it is at location (j)n + i-1 (since start at element 0) so you are given an (7,7) matrix n=7, m=7 you are given i=6, j=1 so it is the (1)7 + 6 element orelement 7+6 = element 13 there are 13 elements before it it is at location 252 so (0,0) is at 252-13=239
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.