Download presentation
Presentation is loading. Please wait.
Published byVictor Curtis Modified over 8 years ago
2
DATA STRUCTURES Application of Stack – Infix to Postfix conversion a Joshua Presentation
3
A+B^C*D$ ABC^D*+ # # + # + ^ # + # + * # + # Infix Form Post fix Form Stack Infix to Postfix conversion Infix to Postfix conversion - Example 1
4
A+B*C^D*E+F ABCD^*E*+F+ Infix Form Post fix Form # + # + * # + * ^ # + * # + # + * # + # # + # # $ Stack Infix to Postfix conversion Infix to Postfix conversion - Example 2
5
Algorithm INFIX_POSTFIX 1. Read a character X from INFIX string. If X = ‘$’ goto (4) 2. If X is an Operand: Add X to the output POSTFIX string. 3. Otherwise, If X is an Operator: 3.1 If Top of Stack has lower precedence Push X onto stack; Goto (1) 3.2 [Top of Stack has higher or equal precedence] Pop from stack (repeatedly) all operators that have higher/equal precedence & add to POSTFIX; Goto(1) 4. Pop all operators still in the stack and add to POSTFIX. 5. Exit.
6
Got it? Goodbye!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.