Professional Documents
Culture Documents
Act. Zone Page 40 (2-4) DSA
Act. Zone Page 40 (2-4) DSA
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
a. Arr[5,20] d. Arr[10,10]
b. Arr[19,43] e. Arr[1,30]
= 1500 + 5 ([(43 -1) 25] + [19 – 1]) = 1500 + 5 ([(30 – 1) 25] + [1 -1])
c. Arr[25,50]
5 words long, compute for the address of the following elements. Starting address
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])
= 1645
c. Arr[25,50]