Advertisement

In-Fix to Post-Fix

In-Fix to Post-Fix Algorithm
1-Create a stack
2-for each character ‘t’ in the input stream {
if (t is an operand)
output t
else if (t is a right parentheses){
POP and output tokens until a left parentheses is popped(but do not output)
}
else {
POP and output tokens until one of lower priority than t is encountered or a left parentheses is encountered
or the stack is empty
PUSH t
}

3-POP and output tokens until the stack is empty.