Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 2(ii)

2 marks

Computer ScienceISC 2024 Computer Science Paper 1NumericalArrays, Strings

Answer the following.

An array ARR [ -5 .....15, 10.....20 ] stores elements in Row Major Wise with each element…

An array ARR [ -5 .....15, 10.....20 ] stores elements in Row Major Wise with each element requiring 2 bytes of storage. Find the address of ARR [10] [15] when the base address is 2500.

Answer

Answer

Rows: $-5$ to $15 \Rightarrow N = 15-(-5)+1 = 21$ Columns: $10$ to $20 \Rightarrow M = 20-10+1 = 11$ Row Major formula: $Address(ARR[i][j]) = Base + W \times [(i-L_r) \times M + (j-L_c)]$ Here $i=10, j=15, L_r=-5, L_c=10, W=2$ $= 2500 + 2 \times [(10-(-5)) \times 11 + (15-10)]$ $= 2500 + 2 \times [165+5] = 2500+340$

Final answer: 2840