English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

A 2D array is declared as A[9,7] and each element requires 2 byte. If A [1,1] is stored in 3000. Find the memory of A[8,5] ?

2006-10-13 06:41:50 · 5 answers · asked by yamuna s 1 in Science & Mathematics Mathematics

5 answers

Oh friend,previous answers are all confusing... look, u haven't mentioned if the array is following Row-Major arrangement or Column-Major arrangement. Anyways, I'm giving u two important formulae, do remember them to wprk on this type of problem, okay ?

Let, a 2D array is declared A[m,n] & each element requires 'e' bytes. A[1,1] is stored in 'B'. U've to find the memory of A[i,j]

(1) For Row-Major arrangement :-
Memory address of A[i,j]= B + [(i*n + j) * e]

(2) For Column-Major arrangement :-
Memory address of A[i,j]= B + [(j*m + i) * e]

[Now, I'm coming to answer of ur question...

for row-major arrangement,
Memory address of A[8,5]= 3000 + [(8*7 + 5) * 2] = 3122

for column-major arrangement,
Memory address of A[8,5]= 3000 + [(5*9 + 8) * 2] = 3106

Hope u've got it clear 'n I've helped u].

2006-10-14 04:12:01 · answer #1 · answered by Innocence Redefined 5 · 2 0

There are two answers, depending on whether stepping by 2 bytes in memory corresponds to stepping by 1 in the first subscript or in the second subscript, because both cases occur. But supposing the first, then stepping by 1 in the second subscript means stepping a whole row, which is 9 * 2 = 18 bytes. So stepping by (8 - 1) = 7 in the first subscript, and (5 - 1) = 4 in the second, means stepping by 7 * 2 + 18 * 4 = 86 bytes hence 3086.

2006-10-13 09:02:29 · answer #2 · answered by Anonymous · 0 0

50

2016-05-21 23:10:32 · answer #3 · answered by ? 4 · 0 0

this question has been posed hundred times , are you al in the same school ?
the answer is 3080 (you have my word until the door)

2006-10-13 06:50:25 · answer #4 · answered by gjmb1960 7 · 0 0

3106

2006-10-13 07:14:14 · answer #5 · answered by ag_iitkgp 7 · 0 0

fedest.com, questions and answers