Advertisements
Advertisements
प्रश्न
Write an algorithm to convert infix to postfix.
लघु उत्तर
Advertisements
उत्तर
- Start.
- Create an empty operator stack and an empty output list.
- Scan the infix expression from left to right.
- Add operands directly to the output.
- Push a left parenthesis onto the stack.
- For a right parenthesis, pop operators to the output until the left parenthesis is found; then remove it.
- For an operator, pop operators having higher or equal precedence, then push the incoming operator.
- Pop all remaining operators to the output.
- Stop.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
