Advertisement
Shailrshah

Rules for converting an Infix string to a Postfix String

Sep 1st, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Switch(char of string)
  2. case operand -> append to postfix string
  3. case '(' -> push on stack
  4. case operator -> if empty stack, push on stack. Otherwise pop all operators of greater or equal precedence until')' or an operator of lower precedence is reached or stack becomes empty and append them to postfix string. Push the operator on stack.
  5. case ')' -> pop operators off the stack, appending them to postfix string. When you encounter a '(', pop it off.
  6. case End of infix string -> pop any remaining operators off the stack and append them to postfix string.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement