dijkstra s two-stack algorithmfpl.cs.depaul.edu/jriely/ds2/extras/demos/13demodijkstra...click to...
TRANSCRIPT
![Page 1: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/1.jpg)
Algorithms, 4th Edition · Robert Sedgewick and Kevin Wayne · Copyright © 2002–2011 · February 23, 2012 4:05:36 PM
AlgorithmsF O U R T H E D I T I O N
R O B E R T S E D G E W I C K K E V I N W A Y N E
1.3 DIJKSTRA'S TWO-STACK ALGORITHM
click to begin demo
![Page 2: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/2.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
value stack operator stack
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
2
Dijkstra's two-stack algorithm
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
operand operator
infix expression(fully parenthesized)
![Page 3: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/3.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
value stack operator stack
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
3
Dijkstra's two-stack algorithm
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
![Page 4: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/4.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
4
Dijkstra's two-stack algorithm
+ ( ( 2 + 3 ) * ( 4 * 5 ) ) )1
value stack operator stack
![Page 5: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/5.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
5
Dijkstra's two-stack algorithm
+ ( ( 2 + 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
![Page 6: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/6.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
6
Dijkstra's two-stack algorithm
( ( 2 + 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
![Page 7: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/7.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
7
Dijkstra's two-stack algorithm
( ( 2 + 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
![Page 8: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/8.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
8
Dijkstra's two-stack algorithm
( ( 2 + 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
![Page 9: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/9.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
9
Dijkstra's two-stack algorithm
2 + 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
(
![Page 10: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/10.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
10
Dijkstra's two-stack algorithm
+ 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
2
![Page 11: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/11.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
11
Dijkstra's two-stack algorithm
+ 3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
2
![Page 12: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/12.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
12
Dijkstra's two-stack algorithm
2
3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
+
![Page 13: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/13.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
13
Dijkstra's two-stack algorithm
2
3 ) * ( 4 * 5 ) ) )
1
value stack operator stack
+
+
![Page 14: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/14.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
14
Dijkstra's two-stack algorithm
2 +
) * ( 4 * 5 ) ) )
1
value stack operator stack
+
3
![Page 15: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/15.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
15
Dijkstra's two-stack algorithm
2 +
) * ( 4 * 5 ) ) )
1
value stack operator stack
+
3
![Page 16: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/16.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
16
Dijkstra's two-stack algorithm
2 +
3
* ( 4 * 5 ) ) )
1
value stack operator stack
+
)
![Page 17: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/17.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
17
Dijkstra's two-stack algorithm
2+3
* ( 4 * 5 ) ) )
1
value stack operator stack
+
![Page 18: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/18.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
18
Dijkstra's two-stack algorithm
* ( 4 * 5 ) ) )
1
value stack operator stack
+
2+3 = 5
![Page 19: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/19.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
19
Dijkstra's two-stack algorithm
* ( 4 * 5 ) ) )
1
value stack operator stack
+
5
![Page 20: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/20.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
20
Dijkstra's two-stack algorithm
( 4 * 5 ) ) )
1
value stack operator stack
+
5
*
![Page 21: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/21.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
21
Dijkstra's two-stack algorithm
( 4 * 5 ) ) )
1
value stack operator stack
+
5 *
![Page 22: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/22.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
22
Dijkstra's two-stack algorithm
*
( 4 * 5 ) ) )
1
value stack operator stack
+
5
![Page 23: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/23.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
23
Dijkstra's two-stack algorithm
*
* 5 ) ) )
1
value stack operator stack
+
5
4
![Page 24: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/24.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
24
Dijkstra's two-stack algorithm
*
* 5 ) ) )
1
value stack operator stack
+
5
4
![Page 25: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/25.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
25
Dijkstra's two-stack algorithm
*
4
* 5 ) ) )
1
value stack operator stack
+
5
![Page 26: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/26.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
26
Dijkstra's two-stack algorithm
*
4 *
5 ) ) )
1
value stack operator stack
+
5
![Page 27: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/27.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
27
Dijkstra's two-stack algorithm
*
4 *
) ) )
1
value stack operator stack
+
5
5
![Page 28: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/28.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
28
Dijkstra's two-stack algorithm
*
4 *
) ) )
1
value stack operator stack
+
5
5
![Page 29: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/29.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
29
Dijkstra's two-stack algorithm
*
4 *
5
) )
1
value stack operator stack
+
5
)
![Page 30: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/30.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
30
Dijkstra's two-stack algorithm
*
4*5
) )
1
value stack operator stack
+
5
![Page 31: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/31.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
31
Dijkstra's two-stack algorithm
*
4*5
) )
1
value stack operator stack
+
5
= 20
![Page 32: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/32.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
32
Dijkstra's two-stack algorithm
*
) )
1
value stack operator stack
+
5
20
![Page 33: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/33.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
33
Dijkstra's two-stack algorithm
*
)
1
value stack operator stack
+
5
20
)
![Page 34: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/34.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
34
Dijkstra's two-stack algorithm
*
)
1
value stack operator stack
+
520
![Page 35: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/35.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
35
Dijkstra's two-stack algorithm
*
)
1
value stack operator stack
+
520 = 100
![Page 36: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/36.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
36
Dijkstra's two-stack algorithm
)
1
value stack operator stack
+
100
![Page 37: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/37.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
37
Dijkstra's two-stack algorithm
)
1
value stack operator stack
+
100
![Page 38: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/38.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
38
Dijkstra's two-stack algorithm
1
value stack operator stack
+100
![Page 39: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/39.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
39
Dijkstra's two-stack algorithm
1
value stack operator stack
+100 = 101
![Page 40: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/40.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
40
Dijkstra's two-stack algorithm
value stack operator stack
101
![Page 41: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/41.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
41
Dijkstra's two-stack algorithm
value stack operator stack
101
![Page 42: DIJKSTRA S TWO-STACK ALGORITHMfpl.cs.depaul.edu/jriely/ds2/extras/demos/13DemoDijkstra...click to begin demo Value: push onto the value stack. Operator: push onto the operator stack](https://reader035.vdocuments.mx/reader035/viewer/2022071415/610fe91f03b713503d5ada3c/html5/thumbnails/42.jpg)
Value: push onto the value stack.Operator: push onto the operator stack.Left parenthesis: ignore.Right parenthesis: pop operator and two values; push the result ofapplying that operator to those values onto the operand stack.
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
42
Dijkstra's two-stack algorithm
result
101