Advertisements
Advertisements
प्रश्न
Write an algorithm to evaluate a postfix expression.
लघु उत्तर
Advertisements
उत्तर
- Start.
- Create an empty stack.
- Scan the postfix expression from left to right.
- If the symbol is an operand, push it onto the stack.
- If the symbol is an operator, pop the required operands.
- Apply the operator in the correct order and push the result.
- After scanning all symbols, the top element is the result.
- Stop.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
