1.

An array AR [-4…. 6, -2 ….. 12 ], stores elements in Row Major Wise, with the address AR[2] [3] as 4142 . If each element requires 2 bytes of storage, find the Base address.

Answer»

AR [-4,… 6, -2 … 12]

Row- wise order, 

AR[2] [3] = B + W(n(i-1)+(j-1)) 

Given i = 2, j = 3, W = 2 bytes 

B = ? 

n = Uc – Lc + 1 

= 12 – (-2) + 1 

= 12 + 2 + 1 

= 15 Now, 414 

= B + 2 [15 (2 -(-2)) + (3-(-4))] 

B + 2[60 + 7] 

= 4142 B + 134 

= 4142 or B = 4008



Discussion

No Comment Found

Related InterviewSolutions