Question: Show a simple code following this Algorithm by right order!!! Algorithm: InfixToPostfix Input: Infix expression I, a temporary empty stack S Output: Postfix expression P

Show a simple code following this Algorithm by right order!!!

Algorithm: InfixToPostfix Input: Infix expression I, a temporary empty stack S Output: Postfix expression P (which is initially empty) corresponding to the Infix expression I 1. for each symbol in I from left to right do 2. if the symbol is an operand then 3. Append the symbol to P 4. else-If the symbol is an operator then 5. Pop every operator on S that is above the most recently scanned left parenthesis and has precedence higher than or equal to that of the new operator symbol, and then append to P 6. Push the new operator symbol onto S 7. else-If the symbol is an opening (left) parenthesis then 8. Push the symbol onto S 9. else-If the symbol is a closing (right) parenthesis then 10. all operators down to the most recently scanned left parenthesis are be popped from S and appended to P 11. discard this pair of parentheses 12. end if 13. end for 14. Pop all operators from S and append to P

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!