data structures and algorithms - cs.nyu.edu · data structures and algorithms v22.0102 otávio...
TRANSCRIPT
![Page 1: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/1.jpg)
Data Structures and AlgorithmsV22.0102
Otávio Braga
![Page 2: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/2.jpg)
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
![Page 3: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/3.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
![Page 4: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/4.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack:
• Output:
![Page 5: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/5.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack:
• Output: 3
![Page 6: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/6.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: +
• Output: 3
![Page 7: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/7.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: +
• Output: 3 4
![Page 8: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/8.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: + *
• Output: 3 4
![Page 9: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/9.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: + *
• Output: 3 4 5
![Page 10: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/10.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: +
• Output: 3 4 5 *
![Page 11: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/11.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: + /
• Output: 3 4 5 *
![Page 12: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/12.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: + /
• Output: 3 4 5 * 6
![Page 13: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/13.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack: +
• Output: 3 4 5 * 6 /
![Page 14: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/14.jpg)
Infix to Postfix ConversionExample 1
• 3+4*5/6
• Stack:
• Output: 3 4 5 * 6 / +
• Done!
![Page 15: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/15.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
![Page 16: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/16.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack:
• Output:
![Page 17: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/17.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: (
• Output:
![Page 18: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/18.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: (
• Output: 300
![Page 19: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/19.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: ( +
• Output: 300
![Page 20: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/20.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: ( +
• Output: 300 23
![Page 21: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/21.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: (
• Output: 300 23 +
![Page 22: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/22.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack:
• Output: 300 23 +
![Page 23: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/23.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: *
• Output: 300 23 +
![Page 24: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/24.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: * (
• Output: 300 23 +
![Page 25: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/25.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: * (
• Output: 300 23 + 43
![Page 26: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/26.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: * ( -
• Output: 300 23 + 43
![Page 27: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/27.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: * ( -
• Output: 300 23 + 43 21
![Page 28: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/28.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: * (
• Output: 300 23 + 43 21 -
![Page 29: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/29.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: *
• Output: 300 23 + 43 21 -
![Page 30: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/30.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack:
• Output: 300 23 + 43 21 - *
![Page 31: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/31.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: /
• Output: 300 23 + 43 21 - *
![Page 32: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/32.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: / (
• Output: 300 23 + 43 21 - *
![Page 33: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/33.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: / (
• Output: 300 23 + 43 21 - * 84
![Page 34: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/34.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: / ( +
• Output: 300 23 + 43 21 - * 84
![Page 35: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/35.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: / ( +
• Output: 300 23 + 43 21 - * 84 7
![Page 36: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/36.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: / (
• Output: 300 23 + 43 21 - * 84 7 +
![Page 37: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/37.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack: /
• Output: 300 23 + 43 21 - * 84 7 +
![Page 38: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/38.jpg)
Infix to Postfix ConversionExample 2
• (300+23)*(43-21)/(84+7)
• Stack:
• Output: 300 23 + 43 21 - * 84 7 + /
• Done!
![Page 39: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/39.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
![Page 40: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/40.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack:
• Output:
![Page 41: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/41.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: (
• Output:
![Page 42: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/42.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: (
• Output: 4
![Page 43: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/43.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: ( +
• Output: 4
![Page 44: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/44.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: ( +
• Output: 4 8
![Page 45: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/45.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: (
• Output: 4 8 +
![Page 46: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/46.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack:
• Output: 4 8 +
![Page 47: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/47.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: *
• Output: 4 8 +
![Page 48: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/48.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: * (
• Output: 4 8 +
![Page 49: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/49.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: * (
• Output: 4 8 + 6
![Page 50: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/50.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: * ( -
• Output: 4 8 + 6
![Page 51: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/51.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: * ( -
• Output: 4 8 + 6 5
![Page 52: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/52.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: * (
• Output: 4 8 + 6 5 -
![Page 53: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/53.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: *
• Output: 4 8 + 6 5 -
![Page 54: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/54.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack:
• Output: 4 8 + 6 5 - *
![Page 55: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/55.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: /
• Output: 4 8 + 6 5 - *
![Page 56: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/56.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / (
• Output: 4 8 + 6 5 - *
![Page 57: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/57.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( (
• Output: 4 8 + 6 5 - *
![Page 58: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/58.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( (
• Output: 4 8 + 6 5 - * 3
![Page 59: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/59.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( ( -
• Output: 4 8 + 6 5 - * 3
![Page 60: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/60.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( ( -
• Output: 4 8 + 6 5 - * 3 2
![Page 61: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/61.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( (
• Output: 4 8 + 6 5 - * 3 2 -
![Page 62: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/62.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / (
• Output: 4 8 + 6 5 - * 3 2 -
![Page 63: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/63.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( *
• Output: 4 8 + 6 5 - * 3 2 -
![Page 64: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/64.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( * (
• Output: 4 8 + 6 5 - * 3 2 -
![Page 65: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/65.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( * (
• Output: 4 8 + 6 5 - * 3 2 - 2
![Page 66: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/66.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( * ( +
• Output: 4 8 + 6 5 - * 3 2 - 2
![Page 67: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/67.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( * ( +
• Output: 4 8 + 6 5 - * 3 2 – 2 2
![Page 68: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/68.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( * (
• Output: 4 8 + 6 5 - * 3 2 – 2 2 +
![Page 69: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/69.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / ( *
• Output: 4 8 + 6 5 - * 3 2 – 2 2 +
![Page 70: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/70.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: / (
• Output: 4 8 + 6 5 - * 3 2 – 2 2 + *
![Page 71: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/71.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack: /
• Output: 4 8 + 6 5 - * 3 2 – 2 2 + *
![Page 72: Data Structures and Algorithms - cs.nyu.edu · Data Structures and Algorithms V22.0102 Otávio Braga. Infix to Postfix Conversion •We use a stack •When an operand is read, output](https://reader033.vdocuments.site/reader033/viewer/2022042711/5f80b09e8e28946a3f6caa0b/html5/thumbnails/72.jpg)
Infix to Postfix ConversionExample 3
• (4+8)*(6-5)/((3-2)*(2+2))
• Stack:
• Output: 4 8 + 6 5 - * 3 2 – 2 2 + * /
• Done!