MCQ Infix Postfix Prefix
MCQ Infix Postfix Prefix
MCQ Infix Postfix Prefix
1. Which of the following is true about infix, postfix, and prefix expressions?
a) Infix expressions require parentheses for precedence, while postfix and prefix
expressions do not.
b) Postfix expressions require parentheses for operator precedence.
c) Prefix expressions cannot be evaluated without parentheses.
d) Infix and postfix expressions are evaluated from right to left.
Answer: a) Infix expressions require parentheses for precedence, while postfix and prefix
expressions do not.
2. Which data structure is most suitable for converting an infix expression to a postfix
expression?
a) Queue
b) Stack
c) Array
d) Tree
Answer: b) Stack
3. Which of the following infix expressions corresponds to the postfix expression AB+C*?
a) (A + B) * C
b) A * (B + C)
c) A + B * C
d) (A * B) + C
Answer: a) (A + B) * C
6. Which of the following is the correct postfix conversion of the infix expression A * (B + C)
/ D?
a) A B C + * D /
b) A * B + C / D
c) A B * C D + /
d) A B + C * D /
Answer: a) A B C + * D /
8. Which of the following steps is NOT part of the process to convert an infix expression to
postfix?
a) Operands are added directly to the output.
b) Operators are pushed onto a stack based on precedence.
c) Parentheses are ignored.
d) Higher precedence operators are popped from the stack before lower precedence
ones.
Answer: c) Parentheses are ignored.
10. Which of the following is true about postfix and prefix expressions?
a) Postfix and prefix expressions always need parentheses for evaluation.
b) In postfix expressions, operators appear before their operands.
c) In prefix expressions, operators appear before their operands.
d) Postfix expressions are easier to evaluate than prefix expressions.
Answer: c) In prefix expressions, operators appear before their operands.
11. What is the time complexity of converting an infix expression to a postfix expression
using a stack?
a) O(n^2)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: c) O(n)
12. Which of the following is the correct postfix form of the expression A * B + C / D?
a) A B * C D / +
b) A B C * + D /
c) A B * C / D +
d) A B * + C / D
Answer: a) A B * C D / +
13. Which of the following is the prefix form of the infix expression A * B + C / D?
a) * + A B / C D
b) + * A B / C D
c) * A B / + C D
d) / + * A B C D
Answer: b) + * A B / C D
14. Which of the following postfix expressions is equivalent to the infix expression (A + B) *
(C + D)?
a) A B C D + * +
b) A B + C D + *
c) A + B * C + D
d) A B + * C D +
Answer: b) A B + C D + *
18. Which of the following describes an advantage of using postfix expressions for
evaluation?
a) Parentheses are required to maintain operator precedence.
b) It is more readable than infix expressions.
c) Postfix expressions eliminate the need for operator precedence rules.
d) Postfix expressions are evaluated from right to left.
Answer: c) Postfix expressions eliminate the need for operator precedence rules.
20. Which of the following is true about the evaluation of prefix expressions?
a) It is evaluated from right to left using a stack.
b) It is evaluated from left to right using a stack.
c) No stack is required to evaluate prefix expressions.
d) It is evaluated using recursion instead of a stack.
Answer: a) It is evaluated from right to left using a stack.