Home ► Lab Exercise ► Data Structures Lab Exercise Programs ► Conversion Of Postfix Expression to Infix Expression▼
Conversion Of Postfix Expression to Infix Expression:
Notation in which the operator separates its operands. Eg (a + b) * c. Infix notation requires the use of brackets to specify the order of evaluation.
Reverse Polish Notation or Suffix Notation in which the operator follows its operands. Eg a + b * c represented as abc*+.
C Program To Convert Postfix Expression To Infix Expression
- Scan the Infix string from left to right.
- Initialize an empty stack.
- If the scanned character is an operand, add it to the Postfix string. If the scanned character is an operator and if the stack is empty push the character to stack.
If the scanned character is an Operator and the stack is not empty, compare the precedence of the character with the element on top of the stack (top Stack). If top Stack has higher precedence over the scanned character pop the stack else push the scanned character to stack. Repeat this step as long as stack is not empty and top Stack has precedence over the character.
- Repeat this step till all the characters are scanned.
After all characters are scanned, we have to add any character that the stack may have to the Postfix string. If stack is not empty add top Stack to Postfix string and Pop the stack. Repeat this step as long as stack is not empty.
⇓ Student Projects ⇓
⇑ Student Projects ⇑