Q. A linear array A is given with lower bound as 1. If address of A[25] is 375 and A[30] is 390, then find address of A[16].
Ans.
Loc (a[k]) = base (a) + w (k-lb)
375 = base (a) + w(25 - 1)
390 = base (a) + w(30 - 1)
375 = x + 24w
390 = x + 29w
15 = 5w
∴ w = 3
∴ x = 375 - 24 *3
x = 375 - 72
x = 303
∴base address is 303 and w = 3.
∴Address of A[16] is
loc = 303+ 3(16-1) = 348.