• Right parenthesis: pop operator and two values; push the result of applying that operator to those values onto the operand stack.. • Right parenthesis: pop operator and two values; pus
Trang 1• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
DATA STRUCTURE AND ALGORITHM
Trang 2• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 2
Resource - Reference
Slides of Robert Sedgewick, and Kevin Wayne,
edit by Dao Nam Anh Major Reference:
• Robert Sedgewick, and Kevin Wayne, “Algorithms”
Princeton University, 2011, Addison Wesley
• Algorithm in C (Parts 1-5 Bundle)- Third Edition by
Robert Sedgewick, Addison-Wesley
Trang 3• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
• Value: push onto the value stack
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 4• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 4
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
Trang 5• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
1
Trang 6• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 6
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
1
Trang 7• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 8• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 8
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
Trang 9• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
Trang 10• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 10
Trang 11• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 12• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 12
Trang 13• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 14• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 14
Trang 15• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 16• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 16
Trang 17• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 18• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 18
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
2 +
3
Trang 19• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 20• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 20
Trang 21• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 22• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 22
Trang 23• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 24• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 24
Trang 25• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 26• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 26
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
* 4
5
Trang 27• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 28• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 28
Trang 29• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 30• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 30
Trang 31• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
5
Trang 32• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 32
5
Trang 33• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 34• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 34
)
Trang 35• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 36• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 36
Trang 37• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Trang 38• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 38
Trang 39• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
1 +
100
Trang 40• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 40
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
1 +
Trang 41• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
101
Trang 42• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Data Structure and Algorithm 42
( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
Thuật toán 2 ngăn xếp của Dijkstra
101
Trang 43• Value: push onto the value stack.
• Operator: push onto the operator stack
• Right parenthesis: pop operator and two values; push the result of
applying that operator to those values onto the operand stack
• Left parenthesis: ignore
Thuật toán 2 ngăn xếp của Dijkstra
result
101