Download presentation
Presentation is loading. Please wait.
1
1 Postfix Demo: The Equation Infix: (1 + (2 * ((3 + (4 * 5)) * 6))) Postfix: 1 2 3 4 5 * + 6 * * + 3+1(2(*((+45*)*)6))()(45*)3(+)(*6)(2*)+1() 3+12*+45**6 4 * 5 = 2020 + 3 = 2323 * 6 = 138138 * 2 = 276 276 + 1 = 277 = 277
2
2 Postfix Demo: The Stack What is a ‘STACK’? At the grocery store, on the canned goods aisle, the cans are STACKED on top of each other. Which one do we take to make sure the stack doesn’t fall over? How did the store worker put the cans into the stack? Where did he or she place the new can? We take the top item and we place new items on the top. So does the computer. To evaluate the problem (1 + (2 * ((3 + (4 * 5)) * 6))), the computer uses a stack and postfix notation. 3+12*+45**6
3
3 Postfix Demo: The Evaluation 3+12*+45**6 3 + 1 2 * + 4 5 * *45=20 3=23 6 6 =138 2=276 1=277 The Stack The Answer
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.