Question
Q.Evaluate the following Postfix expression, showing the stack contents: 250,45,9,/,5,+,20,*,-
(OR)
Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion: A + B * C ^ D - E
CBSECBSE Class XII Board 2019Subjective· 2mImportance★★★★★
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Part (a): the postfix expression 250,45,9,/,5,+,20,*,- evaluates to 50.
Part (b): A + B * C ^ D - E converts to the postfix A B C D ^ * + E -.
Part (a)
A postfix (Reverse Polish) expression carries operator order inside the sequence, so no precedence rules or parentheses are needed. Scan left to right: push every operand; when an operator appears, pop the top two values (the first popped is the right operand, the second is the left), apply the operator, and push the result back. At the end one value remains — the answer.
Token Action Stack (top at right)
250 push [250]
45 push [250, 45]
9 push [250, 45, 9]
/ 45 / 9 = 5 [250, 5]
5 push [250, 5, 5]
+ 5 + 5 = 10 [250, 10]
20 push [250, 10, 20]
* 10 * 20 = 200 [250, 200]
- 250 - 200 = 50 [50]
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.