0% found this document useful (0 votes)
230 views3 pages

Array Question 1

The document discusses address calculation for 2D arrays stored in row major and column major order. It provides examples of calculating addresses of elements for 2D arrays stored in both row major and column major order. It also discusses converting infix expressions to prefix and postfix notation and evaluating postfix expressions by showing the status of the stack.

Uploaded by

Abhishek Sinha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
230 views3 pages

Array Question 1

The document discusses address calculation for 2D arrays stored in row major and column major order. It provides examples of calculating addresses of elements for 2D arrays stored in both row major and column major order. It also discusses converting infix expressions to prefix and postfix notation and evaluating postfix expressions by showing the status of the stack.

Uploaded by

Abhishek Sinha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

1 |Page

Do Your Best, God will Do Rest. By Rajesh Sahu [ PGT Computer Sc]

Address Calculation : Row Major Order : Address of A[I][J]=BA+S[(I-LBR)*N+(J-LBC)] Column Major Order : Address of A[I][J]=BA+S[(I-LBR)+(J-LBC)*M]
Where : BA = Base Address S=Size of elements I,J=Find or determine the location LBR=Lower Bound of row N= Number of columns LBC=Lower bound of column M=UB-LB+1; N=UB-LB+1; Type-1 Q-1 Each element of an array Data[20][50] required 4 bytes of storage, Base address of data is 2000, determine the location of Data[10][10] when the array is stored as (a) row major (b) column major Ans :R-4040, C-2840 Q-2 An array A[11][21] is stored in the memory with each element requiring 2 bytes of storage. If the base address of array in memory is 300, determine the location of a[5][31] when the array is A stored by (i) Row major (ii) Column major Q-3 An array VAL[1....15][1...10] is stored in the memory with each element requiring 4 bytes of storage. If the base address of array VAL is 1500, determine the location of VAL[12][9] when the array VAL is stored (i)rowwise (ii)column-wise Ans :R-1972, C-2024

2 |Page

Q-4 An array ARR[15][35] is stored in the memory along the column with each of its elements occupying 8 bytes. Find out the bas address and the address of an element Arr[2][5], if the location Arr[5][10] is stored at the address 4000. Ans :3376 Q-5 An array Arr[35][15] is stored in the memory along the row with each of its elements occupying 4 bytes. Find the bas address and the address of an element Arr[20][5], if the location Arr[2][2] is stored at the address 3000.

Q-6 An array arr[15][20] is stored in the memory along the row with each element occupying 4 bytes. Find out the base address and address of the element arr[3][2], if the element arr[5][2] is stored at the address 1500. Q-7 An array MAT[30][10] is stored in the memory column wise with each element occupying 8 bytes of memory. Find out the bas address and the address of element MAT[5][7] is stored at the address 1000.

Type-2
Q-1 Convert the following expressions to prefix and postfix form (i) A+B-C(ii) (A+B*C-D)/E*F (III) A+(((B-C*(D-E)+F)/G)*(H-J)

Q-2 Convert the following expression to Postfix expression (i) A*B-(C/D) (ii) A*B+(C-D/F) (iii)(A+B)*C+D/E-F (iv) A+B*C^D-(E/F-G)

(v) A-B+C^D*G/H (Evaluate the postfix expression showing the status of stack at every step gives A=5,B=2, C=4,D=2,E=1,G=6,H=5 (vi) A+(B*C-(D/E F)*G)*H

Q-3 Evaluate the following Postfix notation of expression, show status of stack for each operation : (i) 500,20,30,+,10,*,+ (ii) 120,45,20,+,25,15,-,+,* Ans :1000 Ans :9000

3 |Page (iii)20,45,+,20,10,-,15,+,* (iv) 100,40,8,+,20,10,-,+,* Ans :1625 Ans :5800 Ans :-1/28 Ans :-1/77

(v) 5,11,-,6,8,+,12,*,/ (vi) (vii) (viii) (ix) 5,6,9,+,80,5,*,-,/ 7,2,-,1,14,-,1,2,*,+,5,3,2,4,+,5*,+6,+,-

Ans :34

TRUE, FALSE, TRUE,FALSE, NOT,OR, TRUE, OR, OR, AND

(x) TRUE, FALSE AND, TRUE, TRUE, NOT, OR, AND (xi) TRUE,FALSE,TRUE,NOT FALSE,TRUE OR,NOT,AND, OR,AND

Q-4 Evaluate the following Postfix notation of expression, show status of stack for each operation : (I) (TRUE && FALSE) || !(FALSE||TRUE) Q1- Arrange the following number according Selection Sort 1- 90,40,60,20,80,50,30 2- 15,19,37,54,25,75,7,68 3- 42,29,74,11,65,

You might also like