1. Trang chủ
  2. » Luận Văn - Báo Cáo

Giáo trình bài tập ds4function

182 196 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Trees Huynh Tuong Nguyen, Tran Vinh Tan Chapter 10 Trees Discrete Structures for Computing on 27 May 2014 Huynh Tuong Nguyen, Tran Vinh Tan Faculty of Computer Science and Engineering University of Technology - VNUHCM 10.1 Contents Trees Huynh Tuong Nguyen, Tran Vinh Tan 10.2 Trees Introduction Huynh Tuong Nguyen, Tran Vinh Tan • Very useful in computer science: search algorithm, game winning strategy, decision making, sorting, • Other disciplines: chemical compounds, family trees, organizational tree, / home tan tmp bin mail ls junk music latex scala 10.3 Tree Trees Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph 10.4 Trees Tree Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph G1 G2 G3 G4 10.4 Trees Tree Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph G1 G2 G3 G4 10.4 Trees Tree Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph G1 G2 G3 circuit exists G4 10.4 Trees Tree Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph G1 G2 G3 circuit exists G4 10.4 Trees Tree Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph G1 G2 G3 circuit exists G4 not connected 10.4 Trees Tree Huynh Tuong Nguyen, Tran Vinh Tan Definition A tree (cây ) is a connected undirected graph with no simple circuits Consequently, a tree must be a simple graph G1 G2 G3 circuit exists G4 not connected Definition Graphs containing no simple circuits that are not necessarily connected is forest (rừng ), in which each connected component is a tree 10.4 Trees Prim’s Algorithm (Nearest-Neighbor) Huynh Tuong Nguyen, Tran Vinh Tan • Pick a vertex to start from • Iteratively absorb smallest edge possible a b c 1 10 e d 10 f 10 g 10.37 Trees Prim’s Algorithm (Nearest-Neighbor) Huynh Tuong Nguyen, Tran Vinh Tan • Pick a vertex to start from • Iteratively absorb smallest edge possible a b c 1 10 e d 10 f 10 g 10.37 Kruskal’s Algorithm (Lightest-Edge) Trees Huynh Tuong Nguyen, Tran Vinh Tan Kruskal’s Algorithm (1958) procedure Kruskal (G) T := empty graph for i := to n − e := any edge in G with smallest weight that does not form a simple circuit when added to T T := T with e added return T 10.38 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Trees Kruskal’s Algorithm (Lightest-Edge) Huynh Tuong Nguyen, Tran Vinh Tan • Iteratively add smallest edge possible a b c 1 10 e d 10 f 10 g 10.39 Exercise Trees Huynh Tuong Nguyen, Tran Vinh Tan Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs 10.40 Trees Exercise Huynh Tuong Nguyen, Tran Vinh Tan Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs a b e d h c f g i j 10.40 Trees Exercise Huynh Tuong Nguyen, Tran Vinh Tan Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs a d b e g f h c i 10.40 Trees Exercise Huynh Tuong Nguyen, Tran Vinh Tan Exercise By using Prim’s and Kruskal’s algorithm, determine minimum spanning tree in the following graphs a b 3 f e h j 3 d g i c k l 10.40 Trees Exercise Huynh Tuong Nguyen, Tran Vinh Tan 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) a b 3 f e h j 3 d g i c k l 10.40 ... 10.8 Trees m-ary tree Huynh Tuong Nguyen, Tran Vinh Tan Definition • m-ary tree (cây m-phân): at most m children on each internal vertex of a rooted tree • full m-ary tree (cây m-phân đầy đủ):... internal vertex has exactly m children • An m-ary tree with m = is called a binary tree (cây nhị phân) Full 3-ary tree Binary tree Full 5-ary tree 3-ary tree 10.9 Trees Ordered Rooted Trees Huynh... Huynh Tuong Nguyen, Tran Vinh Tan Theorem A tree with n vertices has n − edges Theorem A full m-ary tree with i internal vertices contains n = mi + vertices 10.11 Properties & Theorems Trees

Ngày đăng: 08/12/2016, 20:47

Xem thêm: Giáo trình bài tập ds4function

TỪ KHÓA LIÊN QUAN

Mục lục

    Prim's Algorithm

    Kruskal's Algorithm

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN