---
title: "Convert and evaluate A/B-(C+D)*E"
subject: "Data Structure and Algorithm"
chapter: 2
key: "semester_4/data_structure_and_algorithm:postfix-evaluate-ab-slash-cd-e"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/postfix-evaluate-ab-slash-cd-e
site: BCT Engineering
---

# Convert and evaluate A/B-(C+D)*E

Data Structure and Algorithm · Chapter 2: The Stack and Queue

- Asked in: 2068 Bhadra, 6 marks
- Video: [Lec-40: Infix to postfix Conversion using Stack | Infix➡️Postfix Conversion with examples](https://www.youtube.com/watch?v=N1Sr-j-cf4c) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/postfix-evaluate-ab-slash-cd-e
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-2

## Question

Convert the given infix expression A/B-(C+D)*E into equivalent postfix expression showing each step in tabular form and evaluate the obtained postfix expression showing STACK status each time when A=8, B=2, C=3, D=1 and E=1.

## Short answer

Postfix: AB/CD+E*-. Evaluating with A=8, B=2, C=3, D=1, E=1 yields 0.

## Answer

#### Conversion of A / B − (C + D) * E

| Step | Symbol | Stack (bottom → top) | Postfix output |
|---|---|---|---|
| 1 | A | (empty) | A |
| 2 | / | / | A |
| 3 | B | / | AB |
| 4 | - | - | AB/ |
| 5 | ( | -( | AB/ |
| 6 | C | -( | AB/C |
| 7 | + | -(+ | AB/C |
| 8 | D | -(+ | AB/CD |
| 9 | ) | - | AB/CD+ |
| 10 | \* | -\* | AB/CD+ |
| 11 | E | -\* | AB/CD+E |
| end | (pop all) | (empty) | AB/CD+E\*- |

**Postfix:** `AB/CD+E*-`

#### Evaluation with A = 8, B = 2, C = 3, D = 1, E = 1

| Step | Symbol | Action | Stack (bottom → top) |
|---|---|---|---|
| 1 | A | push 8 | 8 |
| 2 | B | push 2 | 8, 2 |
| 3 | / | pop 2 (right), 8 (left); 8 / 2 = 4; push | 4 |
| 4 | C | push 3 | 4, 3 |
| 5 | D | push 1 | 4, 3, 1 |
| 6 | + | pop 1 (right), 3 (left); 3 + 1 = 4; push | 4, 4 |
| 7 | E | push 1 | 4, 4, 1 |
| 8 | \* | pop 1 (right), 4 (left); 4 \* 1 = 4; push | 4, 4 |
| 9 | - | pop 4 (right), 4 (left); 4 - 4 = 0; push | 0 |

**Answer: 0**. Check: 8/2 − (3+1)*1 = 4 − 4 = 0.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. In A/B-(C+D)*E, why is + placed in the postfix before the *?
   A. Because + has higher precedence than *
   B. Because the brackets force C+D to be done first
   C. Because + comes first alphabetically
   D. Because * is right-associative
   Answer: B. Brackets override precedence so C+D is computed before multiplying by E. (Key point: Bracket handling)

2. What is the postfix of A/B-(C+D)*E?
   A. AB/CD+E*-
   B. AB/CD+E-*
   C. ABCD+E*/-
   D. AB/C+DE*-
   Answer: A. A/B gives AB/, (C+D)*E gives CD+E*, and - is applied last. (Key point: Postfix result)

3. When evaluating AB/CD+E*- with A=8, B=2, what is the stack after '/' is applied?
   A. 8, 2
   B. 16
   C. 4
   D. 6
   Answer: C. Pop 2 (right) and 8 (left); 8/2 = 4 is pushed. (Key point: Stack after first operator)

4. With A=8,B=2,C=3,D=1,E=1, what is the final value?
   A. 4
   B. 8
   C. -4
   D. 0
   Answer: D. 4 - (3+1)*1 = 4 - 4 = 0. (Key point: Final value)

## Close variants set in other exams

- [Convert and evaluate (A+B)*(C-D)](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Apostfix-evaluate-ab-cd) — Data Structure and Algorithm, chapter 2, asked 2×

## Related in Data Structure and Algorithm

- [Convert expression to prefix and postfix](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Ainfix-prefix-postfix-tabular) — Data Structure and Algorithm, chapter 2
- [Importance of postfix; convert expression](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Apostfix-importance-conversion) — Data Structure and Algorithm, chapter 2
- [Evaluate postfix expression 574-*8/4+](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Apostfix-evaluate-574) — Data Structure and Algorithm, chapter 2
- [Infix to postfix and evaluation](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Ainfix-postfix-explain-evaluate) — Data Structure and Algorithm, chapter 2
- [Convert expression to prefix and postfix](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aprefix-postfix-abcdefgk) — Data Structure and Algorithm, chapter 2
- [Algorithm for infix to postfix conversion](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Ainfix-postfix-algorithm) — Data Structure and Algorithm, chapter 2, asked 3×
