Shunting-yard algorithm

Report a typo

For each character, find the correct action that you do in the shunting-yard algorithm.

Note: choose the order in which "Puts incoming symbol onto the stack (1)" comes before "Puts incoming symbol onto the stack (2)".

Match the items from left and right columns
( (
) )
operand
operator, operator's stack is empty
operator (priority is higher than the operator at the top of the stack)
operator (priority is lower than the operator at the top of the stack)
operator (priority is same as the operator at the top of the stack)
Stack's top operator moves to the output. Incoming operator is compared with the new vertex of the stack
Moves stack items in the output, until it finds the ((
Puts incoming symbol in the output
Puts incoming symbol onto the stack (2)
Moves the incoming operator to the top of the stack
Puts incoming symbol onto the stack (1)
Stack's top operator moves to the output. Incoming operator goes to the stack

Create a free account to access the full topic