Question 6 of 7intermediate🔧 ApplyLong Answer4 marks

Convert the following infix notations to postfix notations, showing stack and string contents at each step.

(a)

A + B - C * D

Answer

AB+CD*-

(b)

A * (( C + D)/E)

Answer

ACD+E/*

Explanation

The conversion follows Algorithm 3.1 from the textbook where operands are added to postExp string and operators are pushed onto the stack based on precedence. When an operator with lower or equal precedence is encountered, operators from the stack are popped to postExp. Parentheses are handled by pushing '(' onto stack and popping until '(' when ')' is encountered.