Your question implies that that the lower bound of each index is 1,
so we are talking about a homogeneous array of 63 elements (each occupying 2 bytes of memory).
The answer depends somewhat upon the language and the implementation (and, sometimes, even the processor). Some store arrays in row order:
X(1,1), followed by X(2,1), X(3,1), ..., X(7,1), then X(1,2),X(2,2),X(3,2) ...
while others store in column order:
X(1,1), X(1,2), X(1,3), ....X(1,9), then X(2,1),X(2,2), X(2,3) ...
while some guarantee no semantics regarding storage, some pad with "green words" (e.g. to round up to a word-size or boundary), and some are processor dependent.
If we assume row order, then the element X(5,1) is the first element on the 5th row and it occurs after 4 full rows of 9 (2-byte) elements each, or 72 bytes beyond X(1,1).
Then (assuming no green word padding, processor quirks, etc), the address of X(5,1) would be:
= 1258 + 4*9*2
= 1258 + 72
= 1330
Now, X(5, 8) appears SEVEN elements later (not eight), which adds 14 bytes to the address: 1344
Since that is not one of your multiple-guess choices, let's try column order: element X(1,8) occurs after 7 full columns of 7 elements each (at 2-bytes per pop), which means that its address is:
1258 + 7*7*2
= 1258 + 98
= 1356
Then, skipping over four elements, to go from X(1,8) to X(5,8) we have:
1356 + 4*2
=1364
That's not one of your choices, either.
Try checking my arithmetic; maybe I added or counted or multiplied wrong (in my head). If not, I don't know what else to tell you.
----
The whole array occupies only 126 bytes, so 1460 is ridiculous.
1356 is a trap -- it's the address of the first element of the column, in column order. 1370 is what you get when you add 14 to it, which is skipping over 7 elements -- but you're looking for X(5,8) not X(8,8).
Ordinarily, I would eliminate the odd address (choice 3).
However, on small-endian architectures, the more-significant byte occurs at the higher address, so that might add 1 to the address you are looking for. It's tempting take the column-order address and add 1 to it, to get the high-order byte -- but that's NOT how addresses are used (even on little-endian machines), and I doubt the question was intended that way.
.
2007-10-01 07:21:51
·
answer #2
·
answered by bam 4
·
0⤊
0⤋
Assuming X(1,2) is stored at decimal 1260 and x(1,3) is stored at decimal 1262, then X(5,8) will be the 4*9+8 = 44th element. So it should be stored at address
1258 + 43*2= 1344.
None of your answers seems correct.
2007-10-01 07:10:43
·
answer #4
·
answered by ironduke8159 7
·
0⤊
0⤋