The document describes the process for converting expressions in infix notation to postfix notation. It explains that operands are output directly and operators are pushed onto a stack. When an operator is encountered, lower precedence operators are popped off the stack first. Opening parentheses are pushed and closing parentheses trigger popping until the matching opening parentheses is found. Three examples are shown step-by-step to demonstrate the algorithm.
The document describes the process for converting expressions in infix notation to postfix notation. It explains that operands are output directly and operators are pushed onto a stack. When an operator is encountered, lower precedence operators are popped off the stack first. Opening parentheses are pushed and closing parentheses trigger popping until the matching opening parentheses is found. Three examples are shown step-by-step to demonstrate the algorithm.
The document describes the process for converting expressions in infix notation to postfix notation. It explains that operands are output directly and operators are pushed onto a stack. When an operator is encountered, lower precedence operators are popped off the stack first. Opening parentheses are pushed and closing parentheses trigger popping until the matching opening parentheses is found. Three examples are shown step-by-step to demonstrate the algorithm.
The document describes the process for converting expressions in infix notation to postfix notation. It explains that operands are output directly and operators are pushed onto a stack. When an operator is encountered, lower precedence operators are popped off the stack first. Opening parentheses are pushed and closing parentheses trigger popping until the matching opening parentheses is found. Three examples are shown step-by-step to demonstrate the algorithm.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online from Scribd
Download as pdf or txt
You are on page 1of 72
Data Structures and Algorithms
V22.0102 Otvio Braga
Infix to Postfix Conversion
We use a stack When an operand is read, output it When an operator is read Pop until the top of the stack has an element of lower precedence Then push it
When ) is found, pop until we find the matching (
( has the lowest precedence when in the stack but has the highest precedence when in the input When we reach the end of input, pop until the stack is empty