1 / 3

Postfix Demo: The Equation

(. 1. +. (. 2. *. (. (. 3. +. (. 4. *. 5. ). ). *. 6. ). ). ). (. 1. (. 2. (. (. 3. (. 4. 5. ). *. ). +. 6. ). *. ). *. ). +. 1. 2. 3. 4. 5. *. +. 6. *. *. +. Postfix Demo: The Equation. Infix: (1 + (2 * ((3 + (4 * 5)) * 6))). = 277. = 277.

Download Presentation

Postfix Demo: The Equation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ( 1 + ( 2 * ( ( 3 + ( 4 * 5 ) ) * 6 ) ) ) ( 1 ( 2 ( ( 3 ( 4 5 ) * ) + 6 ) * ) * ) + 1 2 3 4 5 * + 6 * * + Postfix Demo: The Equation Infix: (1 + (2 * ((3 + (4 * 5)) * 6))) = 277 = 277 Postfix: 1 2 3 4 5 * + 6 * * + 4 * 5 = 20 20 + 3 = 23 23 * 6 = 138 138 * 2 = 276 276 + 1 = 277

  2. 1 2 3 4 5 * + 6 * * + 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. Postfix Demo: The Evaluation 1 2 3 4 5 * + 6 * * + The Stack 5 4 * 5 = 20 4 6 20 3 + 20 = 23 3 138 23 23 * 6 = 138 2 276 1 277 2 * 138 = 276 The Answer 1 + 276 = 277

More Related