Postfix Demo

Post on 10-Jan-2016

25 views 1 download

description

Input. Postfix Demo. 1. 2. 3. 4. 5. *. +. 6. *. *. +. push 1. Input. Top of stack. Postfix Demo. 1. 2. 3. 4. 5. *. +. 6. *. *. +. push 1. 1. Input. Top of stack. Postfix Demo. 1. 2. 3. 4. 5. *. +. 6. *. *. +. 1. Input. Top of stack. Postfix Demo. 1. - PowerPoint PPT Presentation

transcript

1

Postfix Demo

Input

push 1

621 3 4 *5 + ** +

2

Postfix Demo

1

Input

Top of stack

push 1

621 3 4 *5 + ** +

3

Postfix Demo

1

Input

Top of stack

621 3 4 *5 + ** +

4

Postfix Demo

1

Input

Top of stack

2

621 3 4 *5 + ** +

5

Postfix Demo

1

Input

Top of stack

2

621 3 4 *5 + ** +

6

Postfix Demo

1

Input

Top of stack

2 3

621 3 4 *5 + ** +

7

Postfix Demo

1

Input

Top of stack

2 3

621 3 4 *5 + ** +

8

Postfix Demo

1

Input

Top of stack

2 3 4

621 3 4 *5 + ** +

9

Postfix Demo

1

Input

Top of stack

2 3 4

621 3 4 *5 + ** +

10

Postfix Demo

1

Input

Top of stack

2 3 4 5

621 3 4 *5 + ** +

11

Postfix Demo

1

Input

Top of stack

2 3 4 5

pop two elements off the stack and push their product

621 3 4 *5 + ** +

12

Postfix Demo

1

Input

Top of stack

2 3

4 5 *

54

pop two elements off the stack and push their product

621 3 4 *5 + ** +

13

Postfix Demo

1

Input

Top of stack

2 3 20

4 5 *

pop two elements off the stack and push their product

621 3 4 *5 + ** +

14

Postfix Demo

1

Input

Top of stack

2 3 20

pop two elements off the stack and push their sum

621 3 4 *5 + ** +

15

Postfix Demo

1

Input

Top of stack

2

3 20 +

203

pop two elements off the stack and push their sum

621 3 4 *5 + ** +

16

Postfix Demo

1

Input

Top of stack

2

3 20 +

23

pop two elements off the stack and push their sum

621 3 4 *5 + ** +

17

Postfix Demo

1

Input

Top of stack

2 23

621 3 4 *5 + ** +

18

Postfix Demo

1

Input

Top of stack

2 23 6

621 3 4 *5 + ** +

19

Postfix Demo

1

Input

Top of stack

2 23 6

621 3 4 *5 + ** +

20

Postfix Demo

1

Input

Top of stack

2

23 6 *

23 6

621 3 4 *5 + ** +

21

Postfix Demo

1

Input

Top of stack

2 138

23 6 *

621 3 4 *5 + ** +

22

Postfix Demo

621 3 4 *5 + ** +

Input

1

Top of stack

2 138

23

Postfix Demo

Input

Top of stack

1

2 138 *

2 138

621 3 4 *5 + ** +

24

Postfix Demo

1

621 3 4 *5 + ** +

Input

Top of stack

2 138 *

276

25

Postfix Demo

1

621 3 4 *5 + ** +

Input

Top of stack

276

26

Postfix Demo

1

621 3 4 *5 + ** +

Input

Top of stack

276

1 276 +

27

Postfix Demo

277

621 3 4 *5 + ** +

Input

Top of stack

1 276 +

28

Postfix Demo

277

621 3 4 *5 + ** +

Input

Top of stack