Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 43 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
43
Dung lượng
593,53 KB
Nội dung
• • • Value: push onto the value stack Operator: push onto the operator stack Right parenthesis: pop operator and two values; push the result of DATA STRUCTURE AND ALGORITHM applying that operator to those values onto the operand stack • Dijkstra’s Stack Left parenthesis: ignore CẤU TRÚC DỮ LIỆU VÀ GIẢI THUẬT Thuật toán ngăn xếp Dijkstra operator value stack Dr Dao Nam Anh stack Data Structure and Algorithm Resource - Reference • • • Value: push onto the value stack Slides of Robert Sedgewick, and Operator: push onto the operator stack Kevin Wayne, editparenthesis: by Dao Nam Anh Major Reference: Right pop operator and two values; push the result of applying that operator to those values onto the operand stack • Robert Sedgewick, and Kevin Wayne, “Algorithms” • Left parenthesis: ignore Princeton University, 2011, Addison Wesley • Algorithm in C (Parts 1-5 Bundle)- Third Edition by Robert Sedgewick, Addison-Wesley value stack operator stack Data Structure and Algorithm Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 ( + operator stack value stack infix expression (fully parenthesized) ( ( operand + ) * ( * operator Data Structure and Algorithm ) ) ) Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 10 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 * * + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 29 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 * * + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 30 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 5 * + + ( ( + operator stack value stack ( * ) * ( * Data Structure and Algorithm ) ) ) 31 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 5 * + + ( ( + = 20 operator stack value stack ( * ) * ( * Data Structure and Algorithm ) ) ) 32 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 20 * + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 33 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 20 * + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 34 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 20 1 + ( ( + + operator stack value stack ( * ) * ( * Data Structure and Algorithm ) ) ) 35 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 20 1 + ( ( + = 100 + operator stack value stack ( * ) * ( * Data Structure and Algorithm ) ) ) 36 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 100 + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 37 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 100 + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 38 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 100 + ( ( + operator stack value stack ( + ) * ( * Data Structure and Algorithm ) ) ) 39 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 100 + ( ( + = 101 operator stack value stack ( + ) * ( * Data Structure and Algorithm ) ) ) 40 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 101 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 41 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 101 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 42 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore 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 result 101 operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 43 ... University, 20 11, Addison Wesley • Algorithm in C (Parts 1-5 Bundle)- Third Edition by Robert Sedgewick, Addison-Wesley value stack operator stack Data Structure and Algorithm Thuật tốn ngăn xếp Dijkstra. .. stack + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 21 Thuật toán ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore Operator:... * + operator stack value stack ( + ( ( + ) * ( * Data Structure and Algorithm ) ) ) 22 Thuật tốn ngăn xếp Dijkstra • • • Value: push onto the value stack • Left parenthesis: ignore Operator: