This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Infix to Postfix Conversion”.

1. When an operand is read, which of the following is done?

a) It is placed on to the output

b) It is placed in operator stack

c) It is ignored

d) Operator stack is emptied

View Answer

Explanation: While converting an infix expression to a postfix expression, when an operand is read, it is placed on to the output. When an operator is read, it is placed in the operator stack.

2. What should be done when a left parenthesis ‘(‘ is encountered?

a) It is ignored

b) It is placed in the output

c) It is placed in the operator stack

d) The contents of the operator stack is emptied

View Answer

Explanation: When a left parenthesis is encountered, it is placed on to the operator stack. When the corresponding right parenthesis is encountered, the stack is popped until the left parenthesis and remove both the parenthesis.

3. Which of the following is an infix expression?

a) (a+b)*(c+d)

b) ab+c*

c) +ab

d) abc+*

View Answer

Explanation: (a+b)*(c+d) is an infix expression. +ab is a prefix expression and ab+c* is a postfix expression.

4. What is the time complexity of an infix to postfix conversion algorithm?

a) O(N log N)

b) O(N)

c) O(N^{2})

d) O(M log N)

View Answer

Explanation: The time complexity of an infix to postfix expression conversion algorithm is mathematically found to be O(N).

5.What is the postfix expression for the corresponding infix expression?

a+b*c+(d*e)

a) abc*+de*+

b) abc+*de*+

c) a+bc*de+*

d) abc*+(de)*+

View Answer

Explanation: Using the infix to postfix expression conversion algorithm, the corresponding postfix expression is found to be abc*+de*+.

6. Parentheses are simply ignored in the conversion of infix to postfix expression.

a) True

b) False

View Answer

Explanation: When a parenthesis is encountered, it is placed on the operator stack. When the corresponding parenthesis is encountered, the stack is popped until the other parenthesis is reached and they are discarded.

7. It is easier for a computer to process a postfix expression than an infix expression.

a) True

b) False

View Answer

Explanation: Computers can easily process a postfix expression because a postfix expression keeps track of precedence of operators.

8. What is the postfix expression for the infix expression?

a-b-c

a) -ab-c

b) ab – c –

c) – -abc

d) -ab-c

View Answer

Explanation: The corresponding postfix expression for the given infix expression is found to be ab-c- and not abc- -.

9. What is the postfix expression for the following infix expression?

a/b^c-d

a) abc^/d-

b) ab/cd^-

c) ab/^cd-

d) abcd^/-

View Answer

Explanation: Using the infix to postfix conversion algorithm, the corresponding postfix expression for the infix expression is found to be abc^/d-.

10. Which of the following statement is incorrect with respect to infix to postfix conversion algorithm?

a) operand is always placed in the output

b) operator is placed in the stack when the stack operator has lower precedence

c) parenthesis are included in the output

d) higher and equal priority operators follow the same condition

View Answer

Explanation: Parentheses are not included in the output. They are placed in the operator stack and then discarded.

11. In infix to postfix conversion algorithm, the operators are associated from?

a) right to left

b) left to right

c) centre to left

d) centre to right

View Answer

Explanation: In infix, prefix and postfix expressions, the operators are associated from left to right and not right to left.

12. What is the corresponding postfix expression for the given infix expression?

a*(b+c)/d

a) ab*+cd/

b) ab+*cd/

c) abc*+/d

d) abc+*d/

View Answer

Explanation: Using the infix to postfix conversion algorithm, the corresponding postfix expression is obtained as abc+*d/.

13. What is the corresponding postfix expression for the given infix expression?

a+(b*c(d/e^f)*g)*h)

a) ab*cdef/^*g-h+

b) abcdef^/*g*h*+

c) abcd*^ed/g*-h*+

d) abc*de^fg/*-*h+

View Answer

Explanation: Using the infix to postfix expression conversion algorithm using stack, the corresponding postfix expression is found to be abcdef^/*g*h*+.

14. What is the correct postfix expression for the following expression?

a+b*(c^d-e)^(f+g*h)-i

a) abc^de-fg+*^*+i-

b) abcde^-fg*+*^h*+i-

c) abcd^e-fgh*+^*+i-

d) ab^-dc*+ef^gh*+i-

View Answer

Explanation: The postfix expression for the given infix expression is found to be abcd^e-fgh*+^*+i- when we use infix to postfix conversion algorithm.

15. From the given Expression tree, identify the correct postfix expression from the list of options.

a) ab*cd*+

b) ab*cd-+

c) abcd-*+

d) ab*+cd-

View Answer

Explanation: From the given expression tree, the infix expression is found to be (a*b)+(c-d). Converting it to postfix, we get, ab*cd-+.

**Sanfoundry Global Education & Learning Series – Data Structure.**

To practice all areas of Data Structure, __here is complete set of 1000+ Multiple Choice Questions and Answers__.

**If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]**

**Related Posts:**

- Apply for Computer Science Internship
- Practice Programming MCQs
- Check Programming Books
- Check Data Structure Books
- Check Computer Science Books