Test Yourself - (Add, Prefix, Output)
Test Yourself - (Add, Prefix, Output)
1. An array A[-4…6, -2 ….12], stores elements in Row Majorwise, with address A[2][3] is
4142. If each element requires 2 bytes of storage, find the base address.
2. Convert the following infix notation to postfix notation: (X + Y) / (Z * W / V)
3. The following function check( ) is a part of some class.
What will the function check( ) return when the value of n=25. Show the working.
int check(int n)
{ if(n <= 1)
return 1;
if( n%2 == 0)
return 1 + check(n/2);
else
return 1 + check(n/2 + 1); }
4. Convert the following infix expression into postfix.
A-B*C/D+E
5. (ii) A matrix A[m][n] is stored with each element requiring 4 bytes of storage. If the base
address at a[1][1] is 1500 and the address at A[4][5] is 1608, determine the number of
Rows of the matrix when the matrix is stored in Column Major Wise.
6. Convert the following infix notation to prefix form.
((A + B) – C * (D / E)) + F
7. Convert the following infix notation to its prefix form:
(A + B) * ( B * C ) / ( C – D * B )
8. A matrix B[10][7] is stored in the memory with each element requiring 2 bytes of storage.If
the base address at B[X][1] is 1012 and the address at B[7][3] is 1060, determine the value
'X' where the matrix is stored in Column Major form.
9. The array D[-2…10][3…8] contains double type elements. If the base address is 4110, find
the address of D[4][5], when the array is stored in Column Major Wise.
10.Convert the infix expression to prefix form:
A + B/C*(D/E*F)
11 The following function check() is a part of some class. What will be the function
check() return when the value of:
i) n = 25 ii) n = 10. Show the dry run/working.
int check(int n)
{
if(n <= 1)
return 1;
if(n%2 = = 0)
return 1 + check( n/2 );
else return 1 + check( n/2 + 1);
}
12. Convert the following infix expression to postfix form:
(P+Q*T – S/E) / A + B
13. A matrix B[ -5 ...10][3.....10] is stored with each element requiring 4 bytes of storage. If the
base address is 1500, determine the address at B[7][8] when the matrix is stored in Column Major
Wise.
14. The following function Sum( ) is a part of some class. What will the function Sum( )
return when the value of n=23568 , a=2 and b=3 respectively. Show the dry run/working:
int Sum(int n, int a, int b)
{
if(n<10)
return n;
else
{
int k=n%10;
if(k%2==0)
return k*a + Sum(n/10, ++a, b);
else
return k*b + Sum(n/10, a, ++b);
}
}