This set of Discrete Mathematics Question Paper focuses on “Interconversion for Prefix, Postfix & Infix Notations”.

1. Evaluation of expression a/b+c*d-e in postfix notation.

a) ab+cd/*-e

b) ab/cd*+e-

c) abc/+d*-e

d) abcd/+*-e

View Answer

Explanation: The expression=a/b+c*d-e

={(ab/)+(cd*)}-e

={(ab/)(cd*)+}-e

={(ab/)(cd*)+}e-

So the output is: ab/cd*+e-

2. Evaluation of 4*5+3/2-9 in prefix notation.

a) *45-/32+9

b) *+453/-29

c) -+*45/329

d) *+/45932

View Answer

Explanation: The expression=4*5+3/2-9

={(4*5)+(3/2)-9}

={(*45)+(/32)-9}

={+(*45)(/32)}-9

=-{+(*45)(/32)9

So the output is; -+*45/329.

3. What is the output of the following if funct1(7)?

Void main() { int n; long int func; scanf(“%d”,&n); func=func1 (n) printf(“%ld!=%ld”,n,func); } long int func1(int n) { if(n==0) { Return 1; } else { return(n*func1(n-1)); } }

a) 128

b) 4320

c) 720

d) 5040

View Answer

Explanation: This is a factorial function of an integer using recursive approach. By running the function on integer 7 we get 5040.

4. Infix to prefix conversion can be done using __________

a) two queues

b) two stacks

c) one stack and two queues

d) one stack

View Answer

Explanation: In the infix expression,the operator appears between the operands and in infix notation if the operator appears before the operands in the expression. For the conversion between them two stacks are used efficiently. The idea is to use one stack for operators and other to store operands.

5. Conversion from prefix to postfix expression can be done _______________

a) using bubble sort

b) using radix sort

c) using two queues

d) in a direct manner

View Answer

Explanation: In a postfix expression, the operators appear after the operands.Conversion from prefix to postfix is done directly that is better than converting the prefix expression in infix and then infix to postfix expression. It gives better efficiency.

6. What is the postfix expression of 9+3*5/(10-4)?

a) 9 3 + * 5 / 10 4 –

b) 9 3 5 + * / 10 4 –

c) 9 3 + 5 * / 10 4 –

d) 9 3 5 * / + 10 – 4

View Answer

Explanation: The expression, 9+3*5/(10-4)

= 9+3*5/(10 4-)

= 9+35/*(10 4-)

= 935/*+(10 4-)

So the output is:9 3 5 / * + 10 4 -.

7. What is the postfix expression of (A+B)-C*(D/E))+F?

a) A B + C D E / * – F +

b) A B C D E + / * F – +

c) A B C + * D E / F + –

d) A B + C – * D E / F +

View Answer

Explanation: The expression is (A+B)-C*(D/E))+F

= (A+B)-C*(DE/)+F

= (A+B)-C*(DE/)F+

= (A+B)-C(DE/)*F+

= (A+B)C(DE/)*-F+

= (AB+)C(DE/)*-F+

So the output is: AB+CDE/*-F+.

8. Convert the following expression into prefix notation.

(g-(f^e/d+c)-ba)

a) ^-/gfed+c-ab

b) -ab/+-ec^dgf

c) -ab-+c/d^efg

d) ab/+-^cde-fg

View Answer

Explanation: Convert it first in postfix notation, we can have

(g-(f^e/d+c)-ba)

= (g-(f^e/dc+)-ba)

= (g-(f^ed/c+)-ba)

= (g-(fe^d/c+)-ba)

= (g-(fe^d/c+)ba-)

= (gfe^d/c+-ba-)

By reversing this expression gives the prefix expression, i.e

-ab-+c/d^efg.

9. What is the postfix expression of the given expression, (2*4-(5+7/3^4)-8)10?

a) 2 4 5 * 7 3 4 ^ / + 8 – – 10

b) 2 4 * ^ 5 7 3 4 / + 8 10 – –

c) 2 4 * 5 7 ^ 3 4 / + – 8 10 –

d) 2 4 * 5 7 3 4 ^ / + – 8 – 10

View Answer

Explanation: By solving we can have,

(2*4-(5+7/3^4)-8)10

= (2*4-(5+7/34^)-8)10

= (2*4-(5+734^/)-8)10

= (2*4-(5734^/+)-8)10

= (2*45734^/+–8)10

= 2*45734^/+-8-10

= 24*5734^/+-8-10

So the output is: 2 4 * 5 7 3 4 ^ / + – 8 – 10.

10. Prefix expression can be evaluated _________

a) from right to left

b) from left to right

c) from the exact middle

d) from second right element

View Answer

Explanation: Expressions are usually evaluated from left to right manner. Prefix expressions follow the normal rule i.e from left to right. Postfix expressions can be evaluated from right to left.

**Sanfoundry Global Education & Learning Series – Discrete Mathematics.**

To practice all questions papers on Discrete Mathematics, __here is complete set of 1000+ Multiple Choice Questions and Answers__.