Question:

Evaluate the given postfix expression:
Expression: 3 5 * 6 2 + 3 -

Updated On: May 28, 2025
  • 39
  • -9
  • 15
  • -17
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Approach Solution - 1

To evaluate the given postfix expression "3 5 * 6 2 + 3 -", follow these steps: 
1. **Initialize an empty stack** to process the operation.
2. **Read the expression from left to right**:
  a. When encountering a number, push it onto the stack.
  b. When encountering an operator, pop two operands from the stack, apply the operator, and push the result back onto the stack.
3. Apply the above steps to the expression:

3 5 *
  - Push 3: [3]
  - Push 5: [3, 5]
  - Encounter "*": Pop 5 and 3, calculate 3 * 5 = 15, push result: [15]
6 2 +
  - Push 6: [15, 6]
  - Push 2: [15, 6, 2]
  - Encounter "+": Pop 2 and 6, calculate 6 + 2 = 8, push result: [15, 8]
3 -
  - Push 3: [15, 8, 3]
  - Encounter "-": Pop 3 and 8, calculate 8 - 3 = 5, push result: [15, 5]
 

4. The final result on the stack is 15.
The complete evaluation results in the expression's value of 15, which is the correct choice from the given options.

Was this answer helpful?
0
0
Hide Solution
collegedunia
Verified By Collegedunia

Approach Solution -2

The evaluation of the postfix expression 3 5 * 6 + 2 3 * - results in 15.

Additional Context:

  • Step-by-Step Evaluation:
    1. Push 3, push 5 → Stack: [3, 5]
    2. Apply * → 3*5=15 → Stack: [15]
    3. Push 6 → Stack: [15, 6]
    4. Apply + → 15+6=21 → Stack: [21]
    5. Push 2, push 3 → Stack: [21, 2, 3]
    6. Apply * → 2*3=6 → Stack: [21, 6]
    7. Apply - → 21-6=15 → Final result

Correct Answer: (3) 15.

Was this answer helpful?
0
0