I'm struggling getting the pseudo code for this.
Scan string left to right for each char If operand add it to string Else if operator add to stack ....
i'm struggling on how to handle ( )s
I'm struggling getting the pseudo code for this.
Scan string left to right for each char If operand add it to string Else if operator add to stack ....
i'm struggling on how to handle ( )s
Have you tried these links yet?
http://www.geocities.com/e_i_search/premshree/web-include/pub/infix-postfix/index.htm
http://www.cis.temple.edu/~koffman/cis223/InfixToPostfix.doc
I am a bit rusty at this, but when you encounter a '(' , you push it onto the stack because it has the highest precedence. I cant remember what to do when you encounter ')', but i think it goes on the stack as well because its the highest precedence.
(
goes on to the stack, then when you get to )
you pop from the stack until you find a (
.
Wikipedia has a more detailed description of the algorithm, supporting functions as well as operators.