img
Question:
Published on: 21 November, 2024

a) Consider the array int a [ 10 ] [ 10 ] and the base address 2000, then calculate the address of the array a [ 2 ] [ 3 ] in the row and column major ordering.

b) Write the advantage of circular queue over linear queue.

Answer:

Ans. a) Formula of Row major order is

Loc(A[j,k])= Base Address + w[n(j-1) + (k-1)] where w is memory cell.

Loc(A[2,3]= 2000 + 2[10(2-1) +(3-1)]

= 2000+ 24

= 2024 ans.

Formula of Coloumn major order is

Loc(A[j,k])= Base Address + w[m(k-1) + (j-1)] where w is memory cell.

Loc(A[2,3]= 2000 + 2[10(3-1) +(2-1)]

= 2000 + 42

= 2042 ans.

 

Ans.

b) In Circular Queue we utilize memory efficiently. because in queue when we delete any element only front increment by 1, but that position is not used later. so when we perform more add and delete operation, memory wastage increase. But in Circular Queue memory is utilized, if we delete any element that position is used later, because it is circular.

Random questions