Infix, Postfix and Prefix MCQs: 12 Solved Questions with Step-by-Step Explanations
Solve 12 expression-notation MCQs in increasing difficulty, from basic stack use to conversions, associativity and maximum operand-stack depth.
KnowledgeGate Team
Exam prep & CS education

You may remember that postfix puts the operator last and prefix puts it first, yet still lose marks when precedence, associativity, operand order or a stack pop reverses the expression. The cure is to work with complete subexpressions, not isolated symbols, especially under time pressure.
Use a stack to preserve operand order during two-way conversion and evaluation. Attempt each question before opening its explanation. More expression practice is organised under Coding & Skills.
Infix, postfix and prefix in one numerical expression
Form | Pattern | Example for 8 + 2 |
|---|---|---|
Infix |
|
|
Prefix |
|
|
Postfix |
|
|
One tree therefore connects all three forms without guesswork.
The expression tree fixes grouping: preorder gives prefix, postorder postfix. For (8 + 2) * (7 - 3) / 5, parentheses come first and multiplication and division associate from the left:
10 * 4 / 5 = 40 / 5 = 8
The prefix form is / * + 8 2 - 7 3 5. The postfix form is 8 2 + 7 3 - * 5 /.
For postfix evaluation, the stack states are 8 -> [8], 2 -> [8,2], + -> [10], 7 -> [10,7], 3 -> [10,7,3], - -> [10,4], * -> [40], 5 -> [40,5], / -> [8]. For subtraction and division, the second popped value is the left operand. Review Stacks and Queues: Operations and Uses if that rule feels unfamiliar.

MCQs 1-2: the stack and the linear-time conversion algorithm
Question 1, Kendriya Vidyalaya Sangathan 2017
Which of the following data structures is most suitable for evaluating postfix expressions?
A. Tree
B. Stack
C. Linked list
D. Queue
Correct answer: B. Stack.
Scan postfix from left to right and push each operand. At an operator, pop the right operand, then the left operand, calculate, and push the result. This last-in, first-out behaviour is exactly what a stack provides. A tree can represent an expression, but it is not the direct evaluation structure asked for in this question.
Question 2, BPSC PGT Tier-1 2023
What is the time complexity of an infix to postfix conversion algorithm?
A. O(N log N)
B. O(N)
C. O(N²)
D. More than one of the above
E. None of the above
Correct answer: B. O(N).
A standard conversion scans N tokens once. Operands go directly to output; operators are each pushed and popped at most once. Constant work per token gives O(N) time. Worst-case auxiliary space is O(N).
MCQs 3-4: a first postfix conversion and the operand-order trap
Question 3, Indian Space Research Organization 2023
In Reverse Polish notation, the expression A∗B+C∗D is written as:
A. AB∗CD∗+
B. A∗BCD∗+
C. AB∗CD+∗
D. A∗B∗CD+
Correct answer: A. AB∗CD∗+.
Multiplication has higher precedence, so the grouping is (A∗B)+(C∗D). The products become AB∗ and CD∗; appending the joining operator gives AB∗CD∗+. The stack sequence A, B, ∗, C, D, ∗, + confirms the same structure.
Question 4, UGC NET Computer Science Paper 2 (December) 2022
Given the expression (A+B*D)/(E-F)+G, consider the following statements:
A. The prefix notation is +/+A*DB-EFG
B. The prefix expression is the reverse of the postfix expression
C. The order of operands in infix expression and postfix expression are the same.
D. The order of operands in infix expression, prefix expression and postfix expression are the same.
Choose the most appropriate answer from the options given below:
A. A, C and D Only
B. C and D Only
C. A and B Only
D. A and D Only
Correct answer: B. C and D Only.
The tree has root +, left child / and right child G. The correct prefix is +/+A*BD-EFG, not the stated form with D before B; postfix is ABD*+EF-/G+. Both preserve operand order A, B, D, E, F, G. Reversing postfix tokens does not produce prefix.
MCQs 5-7: parentheses, left associativity and right-associative exponentiation
Question 5, UGC NET Computer Science 2021
The postfix form of the expression (A + B) * (C * D ‐ E) * F / G is _______ .
A. A B + C D * E – F G / * *
B. A B + C D * E – F * * G /
C. A B + C D * E – * F * G /
D. A B + C D E * – * F * G /
Correct answer: C. A B + C D * E – * F * G /.
Convert (A+B) to AB+ and (C*D-E) to CD*E-. Since * and / associate left, combine as AB+ CD*E- *, then append F * and G /. This gives AB+CD*E-*F*G/. Option A forms FG/ too early.
Question 6, GATE Computer Science 2004
Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is
A. abc × + def ^ ^ -
B. abc × + de ^ f ^ -
C. ab + c × d - e ^ f ^
D. - + a × bc ^ ^ def
Correct answer: A. abc × + def ^ ^ -.
Right associativity groups the exponent as d^(e^f), with postfix def^^. The product b×c gives bc×; adding a gives abc×+. Combining (a+(b×c))-(d^(e^f)) produces abc×+def^^-.
Question 7, GATE Computer Science 1995
The postfix expression for the infix expression A + B × (C + D) / F + D × E is:
A. A B + C D + * F / D + E *
B. A B C D + * F / + D E * +
C. A * B + C D / F * D E + +
D. A + * B C D / F * D E + +
Correct answer: B. A B C D + * F / + D E * +.
Work inside out: (C+D) gives CD+; multiplying by B and dividing by F give BCD+*F/; adding A gives ABCD+*F/+. Treat this as one operand. Since D×E gives DE*, the last addition yields ABCD+*F/+DE*+.
MCQs 8-9: infix to prefix and prefix back to infix
Question 8, Indian Space Research Organization Computer Science May 2017
Choose the equivalent prefix form of the following expression (a + (b − c))* ((d − e)/(f + g − h))
A. * +a − bc /− de − +fgh
B. * +a −bc − /de − +fgh
C. * +a − bc /− ed + −fgh
D. * +ab − c /− ed + −fgh
Correct answer: A. * +a − bc /− de − +fgh.
Build pieces: b-c -> -bc, a+(b-c) -> +a-bc, and d-e -> -de. Left associativity gives f+g-h -> -+fgh, so division is /-de-+fgh. Root multiplication then gives *+a-bc/-de-+fgh, with operand order preserved.
Question 9, Indian Space Research Organization Computer Science 2020
Convert the pre-fix expression to in-fix
–* + ABC* – DE + FG
A. (A – B) × C + (D × E) – (F + G)
B. (A + B) × C – (D – E) × (F + G)
C. (A + B – C) × (D – E) × (F + G)
D. (A + B) × C – (D × E) – (F + G)
Correct answer: B. (A + B) × C – (D – E) × (F + G).
Scan right to left. (F+G) and (D-E) form the right side (D-E)*(F+G); (A+B)*C forms the left. The leading minus produces (A+B)*C-(D-E)*(F+G). Parentheses preserve the grouping.
MCQs 10-11: translate directly between prefix and postfix
Question 10, BPSC PGT Tier-2 2023
The postfix expression equivalent to the prefix expression * + a b - c d is
A. a b + c d - *
B. a b c d + - *
C. a b + c d * -
D. More than one of the above
E. None of the above
Correct answer: A. a b + c d - *.
The leading * has operands +ab and -cd. Convert them to postfix as ab+ and cd-, then append the root operator: ab+cd-*. The infix cross-check is (a+b)*(c-d).
Question 11, UP Police Computer Science Paper 2 - Subject Oriented (Shift I) 2013
Find prefix of following postfix AB*CD/+
A. +*AB/CD
B. +A*B/CD
C. +AB*C/D
D. +AB*/CD
Correct answer: A. +*AB/CD.
Scan postfix left to right while stacking partial prefix strings. AB* becomes *AB; CD/ becomes /CD. The final plus combines them in original operand order as +*AB/CD. Both source and result represent (A*B)+(C/D).
MCQ 12: maximum operand-stack depth
Question 12, IBPS 2023
What is the maximum number of elements present simultaneously in the operand stack while evaluating the postfix expression:
6 2 3 + - 3 8 2 / + *
A. 1
B. 2
C. 3
D. 4
E. None of the above
Correct answer: D. 4.
Trace every token: 6 -> [6]; 2 -> [6,2]; 3 -> [6,2,3]; + -> [6,5]; - -> [1]; 3 -> [1,3]; 8 -> [1,3,8]; 2 -> [1,3,8,2]; / -> [1,3,4]; + -> [1,7]; * -> [7]. The height reaches 4 after the second 2 is pushed. Maximum depth, not final value 7, is required.
The short revision rule
Before accepting any conversion or evaluation, run four checks:
Fix the grouping first.
Remember that
^is normally right-associative when the question says so.On a pop, the second value is the left operand.
Confirm that the final evaluation stack contains exactly one result.
Do these checks every time, even when the notation looks familiar. A short stack trace catches reversed subtraction or division before you choose an option.
Questions 6 and 7 also appear in Stacks and Queues MCQs: 12 Solved, where they sit inside a broad stacks-and-queues survey; here they isolate right-associative exponentiation and nested infix-to-postfix conversion. Redo Questions 6, 8 and 12 without looking. For structured study, use DSA using Java; Zero to Hero is the broader CS route.
Keep learning

Stack Basics and Operations MCQs: 12 Solved Questions with Step-by-Step Explanations
Test stack fundamentals through 12 exam MCQs on LIFO, TOP, array bounds, queue transfers and permutations. Complete traces make every state and answer checkable.

Evaluation of Expressions MCQs: 12 Solved Questions with Stack Traces
Solve 12 expression MCQs step by step. Trace postfix and prefix evaluation, nesting depth, precedence and notation conversion without reversing operands.

Priority Queue MCQs: 12 Solved Questions on Heaps, Deques and Variants
Attempt 12 verified priority queue and queue-variant MCQs, then learn from concise heap, array, circular queue and deque traces.

Circular Queue MCQs: 12 Solved Questions with Step-by-Step Explanations
Solve 12 Circular Queue MCQs in sequence, with exact options and concise explanations for pointer conventions, wrap-around arithmetic and linked queues.