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.

KnowledgeGate Team

Exam prep & CS education

Updated 27 Sep 20267 min read

Expression questions are rarely lost because the arithmetic is hard. They are lost when two popped operands are reversed, associativity is ignored, or prefix and postfix are read like infix. A reliable attempt writes every intermediate stack, checks that one value remains, and treats notation conversion as a separate string-stack operation. In Coding & DSA, choose an option before reading the explanation, then compare the stack after each operator.

The four rules to use before solving any expression MCQ

  1. Scan postfix from left to right. Scan prefix from right to left.

  2. Push every operand.

  3. At a binary operator, pop the right operand first and the left operand second, compute left operator right, then push the result.

  4. For conversion, push partial expression strings instead of numbers.

Calibrate the method with 9 2 - 3 4 + *. Reading left to right gives 9 -> [9], 2 -> [9,2], - -> [7], 3 -> [7,3], 4 -> [7,3,4], + -> [7,7], * -> [49]. The infix cross-check is (9-2)*(3+4)=7*7=49.

A valid postfix or prefix evaluation finishes with one value, never two leftovers.

Spaces matter. They distinguish multi-digit operands such as 10 and 60. A compact string such as 43*25*+8- instead uses single-digit operands. If the push and pop mechanism is not yet automatic, review Stacks and Queues: Operations and Uses before continuing.

Seven stack snapshots evaluating the postfix expression 9 2 - 3 4 + *, ending with 49 as the only value left.

The linked question labels open their individual lesson pages. Questions 3, 10 and 11 use the Eval of Expressions question hub because those three do not have separate lesson pages.

MCQs 1-3: evaluate postfix expressions without reversing operands

Question 1, GATE Computer Science Set 3 2015

The result evaluating the postfix expression 10 5 + 60 6 / * 8 - is

  • A. 284

  • B. 213

  • C. 142

  • D. 71

Correct answer: C. 142.

After reading 10 5, the stack is [10,5]; + replaces them with 15. Scanning 60 6 gives [15,60,6]; / produces [15,10]. Multiplication leaves [150], then scanning 8 gives [150,8]. Finally, the second pop is 150 and the first is 8, so 150-8=142. The final stack is [142].

Question 2, UGC NET Computer Science Paper 2 (December) 2023

What is the result of evaluating the postfix expression "43*25*+8-" ?

  • A. 8

  • B. 14

  • C. 10

  • D. 5

Correct answer: B. 14.

Because the expression is compact, treat every digit as one operand. The first * changes [4,3] to [12]. The next multiplication changes [12,2,5] to [12,10]. Addition gives [22]. After pushing 8, the stack is [22,8]; subtraction calculates 22-8, leaving [14].

Question 3

Evaluate the postfix expression: 5 3 8 * + 4 2 / -

  • A. 27

  • B. 30

  • C. 31

  • D. 32

Correct answer: A. 27.

First, 3*8=24, so the stack becomes [5,24]. Addition gives [29]. Next, 4/2=2, leaving [29,2]. At the final subtraction, the first pop is 2 and the second is 29. Therefore the calculation is 29-2=27, not 2-29.

MCQs 4-6: negative values, nesting depth and why one stack is enough

Question 4, UGC NET Computer Science Paper 2 (December) 2013

What is the value of the postfix expression ?

a b c d + - * (where a = 8, b = 4, c = 2 and d = 5)

  • A. -3/8

  • B. -8/3

  • C. 24

  • D. -24

Correct answer: D. -24.

Substitute the values without changing the order: 8 4 2 5 + - *. Addition gives 2+5=7. For subtraction, 7 is the right operand and 4 is the left, so 4-7=-3. The last multiplication is 8*(-3)=-24. Option C drops the negative sign and is therefore incorrect.

Question 5, UGC NET Computer Science Paper 2 (June) 2014

What is the maximum number of parenthesis that will appear on the stack at any one time for parenthesis expression given by ( ( ) ( ( ) ) ( ( ) ) )

  • A. 2

  • B. 3

  • C. 4

  • D. 5

Correct answer: B. 3.

Add 1 for every ( and subtract 1 for every ). The depths are 1,2,1,2,3,2,1,2,3,2,1,0. The largest value is 3, so three opening parentheses are waiting together at most. This asks for maximum nesting depth, not the total number of parenthesis pairs.

Scan strip for ( ( ) ( ( ) ) ( ( ) ) ) with the running stack depth under each symbol and maximum depth 3 marked.

Question 6, GATE Computer Science 2002

To evaluate an expression without any embedded function calls:

  • A. One stack is enough

  • B. Two stacks are needed

  • C. As many stacks as the height of the expression tree are needed

  • D. A Turing machine is needed in the general case

Correct answer: A. One stack is enough.

For postfix, one operand stack holds unfinished values, and each operator replaces its operands with one result. Prefix uses the same method while scanning from right to left. Parentheses and precedence matter during infix conversion, but this question asks about evaluation without embedded function calls. A second evaluation stack is unnecessary.

MCQs 7-9: evaluate prefix expressions and apply precedence correctly

Question 7, UGC NET Computer Science Paper 2 (August) 2016

Given the following prefix expression :

* + 3 + 3 ^ 3 + 3 3 3

What is the value of the prefix expression ?

  • A. 2178

  • B. 2199

  • C. 2205

  • D. 2232

Correct answer: C. 2205.

Expose the nested operations from the right. First, + 3 3=6. Then ^ 3 6=3^6=729. The enclosing additions give 3+729=732 and 3+732=735. Finally, the leading operator multiplies by the remaining 3: 735*3=2205. Reading the tokens as a flat left-to-right calculation would destroy this structure.

Question 8, ISRO Computer Science 2009

The expression 1 * 2 ^ 3 * 4 ^ 5 * 6 will be evaluated as

  • A. 32^30

  • B. 162^30

  • C. 49152

  • D. 173458

Correct answer: C. 49152.

Exponentiation has precedence over multiplication here. Compute 2^3=8 and 4^5=1024, then substitute: 1*8*1024*6. Now 8*1024=8192, and 8192*6=49152. The other options come from ignoring precedence or regrouping unlike operators.

Question 9, RSSB Computer Science BCI Paper 2 2022

What is the outcome of the prefix expression

+, -, *, 3, 2, /, 8, 4, 1 ?

  • A. 12

  • B. 11

  • C. 5

  • D. 4

Correct answer: C. 5.

Restore the expression tree as + (- (* 3 2) (/ 8 4)) 1. Its inner values are 3*2=6 and 8/4=2. Subtraction gives 6-2=4, and the root addition gives 4+1=5. The commas separate tokens; they do not alter the prefix order.

MCQs 10-12: convert notation and inspect a postfix stack

Question 10

What is the equivalent prefix expression for 7 6 $ 5 * 5 - 1 7 / 9 9 + / +?

  • A. + - $* 5567+99//17

  • B. + - * $ 7655//17+99

  • C. + - $ * 7565/7+/199

  • D. + - * $ 5567//17+99

Correct answer: B. + - * $ 7655//17+99.

Use a stack of prefix strings. 7 6 $ becomes $ 7 6; attaching 5 with *, then 5 with -, gives - * $ 7 6 5 5. Build / 1 7 and + 9 9, then combine them as / / 1 7 + 9 9. The final + yields + - * $ 7 6 5 5 / / 1 7 + 9 9, option B without spaces. Only the binary arity of $ matters.

Question 11

If the expansion (2+3)*4+5*(6+7)*8+9 is evaluated with * having precedence over +, then the value obtained is the same as the value of which of the following prefix expression?

  • A. ++*+234**5+6789

  • B. +*++234**5+6789

  • C. *++234**5++6789

  • D. +*+*234++5*6789

Correct answer: A. ++*+234**5+6789.

Group it as ((2+3)*4)+((5*(6+7))*8)+9. Its value is 5*4 + 5*13*8 + 9 = 20 + 520 + 9 = 549. The products become * + 2 3 4 and * * 5 + 6 7 8. Joining them and adding 9 at the root gives + + * + 2 3 4 * * 5 + 6 7 8 9, which is option A without spaces.

Question 12, ISRO Computer Science 2016

The following postfix expression with single-digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
Here ^ is exponentiation. What are the top two stack elements, listed top to bottom, after the first * is evaluated?

  • A. 6, 1

  • B. 5, 7

  • C. 3, 2

  • D. 1, 5

Correct answer: A. 6, 1.

After 8 2 3 ^, the stack is [8,8] because 2^3=8. Division leaves [1]; pushing 2 and 3 and applying the first * leaves [1,6]. Listed from top to bottom, the two values are 6, 1.

A five-check error screen, answer key and next practice step

Before choosing an option, run this screen:

  1. Identify whether the notation is prefix, postfix or infix.

  2. Tokenise multi-digit operands correctly.

  3. Write every stack bottom-to-top.

  4. For -, / and exponentiation, put the second pop on the left in left op right.

  5. For infix, apply parentheses, precedence and associativity before converting.

The answer key is 1-C, 2-B, 3-A, 4-D, 5-B, 6-A, 7-C, 8-C, 9-C, 10-B, 11-A, 12-A. Redo questions where you omitted an intermediate stack state. Memorising letters will not fix operand order.

For broader conversion algorithms and associativity, solve Infix, Postfix and Prefix MCQs: 12 Solved Questions. For numeric evaluation, keep recording every value-stack state. Then choose Coding for Placements for a wider coding path, or DSA using Java for language-specific DSA practice. Keep the four rules beside you until every reduction is automatic.