Infix to Postfix - PowerPoint PPT Presentation

1 / 3
About This Presentation
Title:

Infix to Postfix

Description:

The left parenthesis. A string postfix which is the final expression ... if ), pop and append to postfix until ( is popped - discard ( and ) ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 4
Provided by: Vander
Category:

less

Transcript and Presenter's Notes

Title: Infix to Postfix


1
Infix to Postfix
2
Convert infix to postfixData Structure
  • Infix expression is terminated by special
    delimiter
  • opStack (a stack) containing
  • Arithmetic operators
  • The left parenthesis
  • A string postfix which is the final expression
  • There is a correspondence between operator and an
    integer given by

3
Algorithm
  • infixPriority equate operator to integer
  • stackPriority equate operator to integer
  • Initialize opStack push()
  • Read ch from infix
  • Test ch
  • if operand, append to postfix
  • if ), pop and append to postfix until ( is popped
    - discard ( and )
  • if , pop all remaining entries and append
  • Otherwise, pop and append operators whose
    stackPriority gt infix Priority, push ch
  • Repeat steps 4, 5 until ch
Write a Comment
User Comments (0)
About PowerShow.com