# 91清大資工所考古題

Let A[I:j,1:k] be a two-dimensional array.Each element of A requires

two bytes.Let A[2,2] be stored at 898 and A[1,3] be stored at 910.

Assume that the memory is addressed by byte and the array is stored

sequenially in memory.

What is the address of A[5,7]??

[(7-1)*(7-3)+5]*2=x-910,=>X=978

Loc(A[5,7])=Loc(A[1,3])+[(7-3)*7-1+5]*2

=910+64

=974

Update:

To Jacob Lee ~

j的值我是這樣算出來的(跟書上的解法式子不同):

Loc(A[1,3]) = Loc(A[2,2]) + [ ( 3 - 2 ) * j - 2 + 1 ] * 2 = 910

==>898 + ( j - 1 ) * 2 = 910

==>j - 1 = 6

Rating

We know that the second column dominates the RAM place from A[1, 3] occupies higher address than A[2, 2].

From A[1:j, 1:k] we know that the subscript begins from 1 not 0.

(910 - 898) / 2 = 6 tells us that there are 6 cells between A[1, 3] and A[2, 2].

From this we know that

j - 2 + 1 = 6 // because (3-2) = 1

j = 7

The location of A[5, 7] is

910 + [ 7*(7-3) + (5-1) ] * 2 = 974

Your expression, Loc(..) , is better than mine!

I think you know how to calculate the brown 7.

That is the only thing you do not show in you calculation.

Good luck on your exam. ^_^

2009-04-12 22:32:57 補充：

I do not look very carefully about the content you 補問。

But it looks correct and the answer is correct.

This means that your concept and calculation is correct.

A Chinese saying is 盡信書不如無書.

2009-04-12 22:33:15 補充：

I worked in a public press for more than 8 years.

It is impossible that there is no error in a book!

That will definitely a miracle!

So, The solution you got from the solution book is definitely wrong on this question.