Overview
The Shunting Yard Algorithm handles precedence and associativity by moving operators from an operator stack to an output queue.
Converts infix expressions to postfix form using operator and output stacks.
Compact metadata for implementation and discovery.
The Shunting Yard Algorithm handles precedence and associativity by moving operators from an operator stack to an output queue.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n)
Worst
O(n)
Space
O(n)
Show tokens moving between an operator stack and output queue.
Shunting Yard Algorithm operates in O(n) time and O(n) space within the Expression Parsing family. Often compared with Pratt Parsing and Dijkstra's Two-Stack Algorithm.
What each reference supports for this entry.
Parsing reference for Shunting Yard Algorithm's control flow, grammar assumptions, and parser construction tradeoffs.
Open sourceOriginal Dijkstra report supporting stack-based expression translation and the shunting-yard parsing method.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Shunting-yard and Pratt parsing are alternative ways to handle expression precedence.