Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 192 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
192
Dung lượng
1,12 MB
Nội dung
Trees Chapter 10 Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Trees Discrete Structures for Computing on January 11, 2017 Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Faculty of Computer Science and Engineering University of Technology - VNUHCM htnguyen@hcmut.edu.vn 10.1 Trees Contents Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Introduction Properties of Trees Tree Traversal Contents Introduction Applications of Trees Binary Search Trees Decision Trees Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees Spanning Trees Spanning Trees Minimum Spanning Trees Prim’s Algorithm Minimum Spanning Trees Kruskal’s Algorithm Prim’s Algorithm Kruskal’s Algorithm 10.2 Trees Course outcomes Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Course learning outcomes L.O.1 Understanding of logic and discrete structures L.O.1.1 – Describe definition of propositional and predicate logic L.O.1.2 – Define basic discrete structures: set, mapping, graphs L.O.2 Represent and model practical problems with discrete structures L.O.2.1 – Logically describe some problems arising in Computing L.O.2.2 – Use proving methods: direct, contrapositive, induction L.O.2.3 – Explain problem modeling using discrete structures Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees L.O.3 L.O.4 Understanding of basic probability and random variables L.O.3.1 – Define basic probability theory L.O.3.2 – Explain discrete random variables Compute quantities of discrete structures and probabilities L.O.4.1 – Operate (compute/ optimize) on discrete structures L.O.4.2 – Compute probabilities of various events, conditional ones, Bayes theorem Decision Trees Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.3 Trees Introduction Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung • Very useful in computer science: search algorithm, game winning strategy, decision making, sorting, • Other disciplines: chemical compounds, family trees, organizational tree, Contents Introduction Properties of Trees / Tree Traversal Applications of Trees home tmp bin Binary Search Trees Decision Trees Spanning Trees tan mail ls junk Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm music latex scala 10.4 Trees Tree Definition Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.5 Trees Tree Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees G1 G2 G3 G4 Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.5 Trees Tree Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees G1 G2 G3 G4 Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.5 Trees Tree Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees G1 G2 G3 circuit exists G4 Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.5 Trees Tree Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees G1 G2 G3 circuit exists G4 Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.5 Trees Tree Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees G1 G2 G3 circuit exists G4 Spanning Trees Minimum Spanning Trees Prim’s Algorithm not connected Kruskal’s Algorithm 10.5 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung • Iteratively add smallest edge possible a b c Contents Introduction Properties of Trees Tree Traversal 1 10 Applications of Trees Binary Search Trees Decision Trees e d Minimum Spanning Trees 10 f 10 Spanning Trees Prim’s Algorithm Kruskal’s Algorithm g 10.42 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung • Iteratively add smallest edge possible a b c Contents Introduction Properties of Trees Tree Traversal 1 10 Applications of Trees Binary Search Trees Decision Trees e d Minimum Spanning Trees 10 f 10 Spanning Trees Prim’s Algorithm Kruskal’s Algorithm g 10.42 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung • Iteratively add smallest edge possible a b c Contents Introduction Properties of Trees Tree Traversal 10 Applications of Trees Binary Search Trees Decision Trees e d Minimum Spanning Trees 10 f 10 Spanning Trees Prim’s Algorithm Kruskal’s Algorithm g 10.42 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung • Iteratively add smallest edge possible a b c Contents Introduction Properties of Trees Tree Traversal 10 Applications of Trees Binary Search Trees Decision Trees e d Minimum Spanning Trees 10 f 10 Spanning Trees Prim’s Algorithm Kruskal’s Algorithm g 10.42 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung • Iteratively add smallest edge possible a b c Contents Introduction Properties of Trees Tree Traversal 10 Applications of Trees Binary Search Trees Decision Trees e d Minimum Spanning Trees 10 f 10 Spanning Trees Prim’s Algorithm Kruskal’s Algorithm g 10.42 Trees Exercise Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.43 Trees Exercise Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs Contents Introduction Properties of Trees a b c Tree Traversal Applications of Trees Binary Search Trees Decision Trees e d f g Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm h i j 10.43 Trees Exercise Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs Contents Introduction Properties of Trees a b 4 c Tree Traversal Applications of Trees Binary Search Trees Decision Trees d e g f Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm h i 10.43 Trees Exercise Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs Contents Introduction a b c d Properties of Trees Tree Traversal Applications of Trees f e Binary Search Trees Decision Trees g h Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm i j k l 10.43 Trees Exercise Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs (and maximum spanning tree (cây khung cực đại) Contents Introduction a b c d Properties of Trees Tree Traversal Applications of Trees f e Binary Search Trees Decision Trees g h Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm i j k l 10.43 Trees Revision Cho hai đồ thị G H sau: Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung B C A D Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees (G) (H) F E Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm Chọn phát biểu A) G B) G H đẳng cấu C) Xố cạnh G thu D) Xố cạnh H thu 10.44 Trees Revision Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung What is the value of each of these prefix expressions? Contents a) - * / Introduction b) ∗ - * 3 * Tree Traversal c) + - ∗ + / - Applications of Trees Properties of Trees d) * + + ∗ + 3 Binary Search Trees Decision Trees Spanning Trees Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.45 Trees Revision Xác định phủ tối thiểu cho đồ thị hình vẽ (áp dụng hai phương pháp) 11 A C E 10 S 10 8 B D F H 14 Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees Spanning Trees G Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm 10.46 Trees Revision Xác định phủ tối thiểu cho đồ thị hình vẽ (áp dụng hai phương pháp) 11 A C E 10 S 10 8 B D F H 14 Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Contents Introduction Properties of Trees Tree Traversal Applications of Trees Binary Search Trees Decision Trees Spanning Trees G Minimum Spanning Trees Prim’s Algorithm Kruskal’s Algorithm By using Prim’s or Kruskal’s algorithm, could we determine a minimum spanning tree in a directed graph? Explain it 10.46 Trees Revision Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Cho G = (V, E) đồ thị đơn vơ hướng bất kỳ, có n đỉnh Định nghĩa đồ thị bù G Gc = (V, F ) thỏa hai tính chất: G ∪ Gc = Kn E ∩ F = ∅ Contents Introduction Properties of Trees Tree Traversal Gọi T bao trùm đồ thị đầy đủ K6 Số lượng cạnh đồ thị bù T c Applications of Trees Binary Search Trees Decision Trees A) Spanning Trees B) 10 Minimum Spanning Trees C) 15 Prim’s Algorithm Kruskal’s Algorithm D) 20 10.47 ... Spanning Trees Prim’s Algorithm Kruskal’s Algorithm e f d g Left subtree of a Right subtree of a 10 .11 Trees Ordered Rooted Trees Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Definition • An... Spanning Trees Prim’s Algorithm Kruskal’s Algorithm e f d g Left subtree of a Right subtree of a 10 .11 Trees Properties & Theorems Huynh Tuong Nguyen, Nguyen An Khuong, Vo Thanh Hung Theorem A tree