You are on page 1of 3

ULYSSES URICH D.

DURAN AI22

2. Given a one-dimensional array with 100 4-word elements, compute for the address

of the following elements. Assume that the starting address of the array is 2300.

a. Arr[5] d. Arr[3]

= 2300 + 4 (5 – 1) = 2300 + 4 (3 – 1)

= 2300 + 16 = 2300 + 8

= 2316 = 2308

b. Arr[72] e. Arr[15]
= 2300 + 4 (15 – 1)
= 2300 + 4 (72 – 1)
= 2300 + 56
= 2300 + 284
= 2356
= 2584

c. Arr[99]

= 2300 + 4 (99 – 1)
= 2300 + 392
= 2692
3. Given a 25 x 50 stored array in memory in column major and where each element

is 5 words long, compute for the address of the following elements. Starting

address of the array is 1500

a. Arr[5,20] d. Arr[10,10]

= 1500 + 5 ([(20 – 1) 25] + [5 – 1]) = 1500 + 5 ([(10 – 1) 25] + [10 -1])

= 1500 + 5 (475 + 4) = 1500 + 5 (225 + 9)

= 1500 + 2395 = 1500 + 1170


= 3895 = 2670

b. Arr[19,43] e. Arr[1,30]

= 1500 + 5 ([(43 -1) 25] + [19 – 1]) = 1500 + 5 ([(30 – 1) 25] + [1 -1])

= 1500 + 5(1050 + 18) = 1500 + 5 (725 + 0)


= 1500 + 5340 = 1500 + 3625
= 6840 = 5125

c. Arr[25,50]

= 1500 + 5 ([(50 – 1) 25] + [25 -1])


= 1500 + 5 (1225 + 24)
= 1500 + 6245
= 7745
4. Given a 25 x 50 stored array in memory in row major and where each element is

5 words long, compute for the address of the following elements. Starting address

of the array is 1500.

a. Arr[5,20] d. Arr[10,10]

= 1500 + 5 ([(5 – 1) 50] + [20 – 1]) = 1500 + 5 ([(10 – 1) 50] + [10 -1])
= 1500 + 5 (200 + 19)
= 1500 + 5 (450 + 9)
= 1500 + 1095
= 1500 + 2295
= 2595
= 3795
b. Arr[19,43]
e. Arr[1,30]
= 1500 + 5 ([(19 – 1) 50] + [43 – 1])
= 1500 + 5 (900 + 42) = 1500 + 5 ([(1 – 1) 50] + [30 -1])

= 1500 + 4710 = 1500 + 5 (29)


= 6210 = 1500 + 145

= 1645
c. Arr[25,50]

= 1500 + 5 ([(25 – 1) 50] + [50 – 1])


= 1500 + 5 (1200 + 49)
= 1500 + 6245
= 7745

You might also like