Discrete Mathematics Chapter-10 Trees. Introduction to Tree (§10.1)  Def 1. A connected (undirected) graph that contains no simple circuits is called.

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
Discrete Structures Lecture 13: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
1 Copyright M.R.K. Krishna Rao 2003 Ch 9 - Trees Definition: A tree is a connected undirected graph with no simple circuits. Since a tree cannot have a.
1 Section 9.1 Introduction to Trees. 2 Tree terminology Tree: a connected, undirected graph that contains no simple circuits –must be a simple graph:
Divide-and-Conquer. 什麼是 divide-and-conquer ? Divide 就是把問題分割 Conquer 則是把答案結合起來.
布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
Discrete Mathematics Transparency No. 8-1 Chapter 8 Trees.
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
Section 1.2 Describing Distributions with Numbers 用數字描述分配.
Instructor: Ching-Chi Lin 林清池 助理教授
Graph V(G 1 )={0, 1, 2, 3, 4, 5, 6, 7, 8, 9} E(G 1 )={(0, 2), (0, 3), (1, 4), (2, 3), (2, 5), (2, 6), (3, 6), (3, 7), (4, 7), (5, 6), (5,
8.1 何謂高度平衡二元搜尋樹 8.2 高度平衡二元搜尋樹的加入 8.3 高度平衡二元搜尋樹的刪除
: The Playboy Chimp ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10611: The Playboy Chimp 解題者:蔡昇宇 解題日期: 2010 年 2 月 28 日 題意:給一已排序的數列 S( 升冪.
: The largest Clique ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11324: The largest Clique 解題者:李重儀 解題日期: 2008 年 11 月 24 日 題意: 簡單來說,給你一個 directed.
: Problem A : MiniMice ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11411: Problem A : MiniMice 解題者:李重儀 解題日期: 2008 年 9 月 3 日 題意:簡單的說,題目中每一隻老鼠有一個編號.
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
Review of Chapter 9 張啟中. Inheritance Hierarchy Min PQ Max PQ Min Heap Mergeable Min PQ DeapMin-Max Min-LeftistMin-SkewMinFHeap MinBHeap DEPQMax Heap Symmetric.
Chapter 10 m-way 搜尋樹與B-Tree
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Trees.
:Count the Trees ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10007:Count the Trees 解題者:楊家豪 解題日期: 2006 年 3 月 題意: 給 n 個點, 每一個點有自己的 Label,
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
Trees and Tree Traversals Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Discrete Mathematics Chapter 10 Trees 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
Discrete Mathematics Chapter 4 Induction and Recursion 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Section 10.1 Introduction to Trees These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 6 th ed., by Kenneth.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
Foundations of Discrete Mathematics
Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Tree Traversal Inorder traversal: A/B*C*D+E (LVR)
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Trees – Chapter 9 Slides courtesy of Dr. Michael P. Frank University of Florida Dept. of Computer & Information Science & Engineering.
Trees Dr. B. Prabhakaran Application Examples Useful for locating items in a list Used in Huffman coding algorithm Study games like.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Chapter 3 Trees and Forests 大葉大學 資訊工程系 黃鈴玲
Discrete Structures Trees (Ch. 11)
Chap 8 Trees Def 1: A tree is a connected,undirected, graph with no simple circuits. Ex1. Theorem1: An undirected graph is a tree if and only if there.
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Chapter 12 Abstract Data Type. Understand the concept of an abstract data type (ADT). Understand the concept of a linear list as well as its operations.
Data Structures -3 rd test- 2015/06/01 授課教授:李錫智. Question 1 Suppose we use an array to implement a sorted list. Please answer the following questions.
CS 103 Discrete Structures Lecture 23 Trees (1). Second Midterm Exam 1 st Lecture in December (same time as the lecture) 75 minute duration Will cover.
Discrete Mathematics Chapter-10 Trees.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: There is a unique simple path between any 2 of its.
CHAPTER 11 TREES INTRODUCTION TO TREES ► A tree is a connected undirected graph with no simple circuit. ► An undirected graph is a tree if and only.
Discrete Mathematics Chapter 10 Trees. Outline 10.1 Introduction to Trees 10.2 Applications of Trees 10.3 Tree Traversal 10.4 Spanning Trees 10.5 Minimal.
Discrete Mathematics Chapter 10 Trees.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Chapter 11. Chapter Summary Introduction to Trees Applications of Trees (not currently included in overheads) Tree Traversal Spanning Trees Minimum Spanning.
Section10.1: Introduction to Trees
Discrete Mathematics Trees.
Chapter 12 Abstract Data Type.
Applied Discrete Mathematics Week 15: Trees
Discrete Mathematicsq
Trees Chapter 11.
Introduction to Trees Section 11.1.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
And the Final Subject is…
Trees Chapter 11.
Presentation transcript:

Discrete Mathematics Chapter-10 Trees

Introduction to Tree (§10.1)  Def 1. A connected (undirected) graph that contains no simple circuits is called a tree.  Trees are particularly useful in computer science, where they are employed in a wide range of algorithms. Construct efficient algorithms for locating items in a list. Construct efficient codes saving costs in data transmission and storage. Study games such as checkers and chess. Model procedure carried out using sequence of decisions.

Nikolaus ( ) Jacob ( ) Nikolaus ( ) Nikolaus ( ) Johann ( ) Nikolaus ( ) Daniel ( ) Johann ( ) Johann ( ) The Bernoulli Family of Mathematicians Jacob ( )

EXAMPLE2 Which of the graphs shown below are trees ? a b c d e f aaa bbb c c c d d d ee e f f f Tree Not a Tree

Theorem 1  An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices.  Pf: T is a tree.  T is connected, no simple circuit.  For any vertices x and y, there is a simple path. If there is a different path from x to y, then two different paths will form a circuit. This is a contradiction. Thus the path is from x to y is unique. Assume that there is a unique path between any two vertices in graph T.  T is connected. Suppose that T contains a simple circuit. Then every pair of vertices in this circuit, say x and y, have two different paths from x to y. That contradicts to the uniqueness of the path. Thus T has no circuit, and then T is a tree.

 Def 1. A rooted tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root. d f g b c a e A root tree with root a A Tree a a b b c c d d e e f f g g A root tree with root c

Terminology  Ancestors  Descendants  parent  Child  Siblings  Leaf  Internal vertex  Subtree

Terminology a b c d e f g h i j k l m A Rooted Tree T a is the parent of f, b and g j is the parent of l and m f is the child of a e is the child of c f, b and g are siblings e and d are siblings a, b are ancestors of c e, c are descendants of b leaves: d, e, f, k, i, l, m internal vertices: others b d c e subtree of b subtree of g

Def 3  A rooted tree is called an m-ary tree if every interval vertex has no more than m children.  The tree is called a full m-ary tree if every interval vertex has exactly m children.  An m-ary tree with m = 2 is called a binary tree.

Example 3 A full binary tree. A full 3-ary tree.

A full 5-ary tree. A m-ary tree. (m  3) Not a full m-ary tree

More Terminology  An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered (from left to right).  In an ordered binary tree (usually called just a binary tree), if an internal vertex has two children, the first child is called the left child and the second one is called the right child.  The tree rooted at the left (right) child of a vertex is called the left (right) subtree of this vertex.

Example 4 a bc d e f g j k h i l m A Binary Tree T The Left Subtree of the Vertex c. h j The Right Subtree of the Vertex c. i k l m

H H H H H H H H H H C C C C H H H H H HH H H H CCC C The Two Isomers of Butane Butane Isobutane Trees as Models

Representing Organizations President VP R&D VP Marketing VP Finance VP Services Director Resourch Director Software Development Director Software Development AVP Sales AVP Marketing Chief Field Operations Chief Field Operations Director Accounting Director MIS

Theorem 2  A tree with n verices has n  1 edges.  Pf: Prove by induction. Let P(n) be the statement “A tree with n verices has n  1 edges.” Basis Step: When n = 1, a tree with one vertex has no edge. P(1) is true. Inductive Step: Assume that P(k) is true. Suppose that T is a tree with k+1 vertices and v is a leaf. Let w is the parent of v. Remove v and the edge connecting v and w. We’ll get a tree T’ with k vertices and then has k  1edges. It follows that T has k edges. Then P(k+1) is true. 

Theorem 3 A full binary tree m = 2, i = 3, 7 vertices. A full 3-ary tree m = 3, i = 4, 13 vertices A full m-ary tree with i internal vertices contains mi+1 vertices.

A full 5-ary tree m = 5, i = 3, 16 vertices Not a full m-ary tree Not satisfy the theorem

Example 9  A chain letter: Each people sends to 4 people. Some people do this, but others do not send any letters. How many people have seen this letter, including the first person, if no one receives more than one letter and if the chain letter ends after there have 100 people who read it but didn’t send it out? How many people sent out the letter?  Sol: This is a 4-ary (m = 4) tree. Note there are n = mi +1 vertices and l = n  i leaves. 100(= l) leaves  n = 4(n  100) + 1  400  1 = 3n  There are n = 133 vertices. There are 133  100 = 33 internal vertices.

Theorem 4  A full m-ary tree with 1. n vertices has i = (n  1)/m internal vertices and l = [(m  1)n + 1]/m leaves, 2. i interval vertices has n = mi + 1 vertices and l = (m  1)i + 1 leaves, 3. l leaves has n = (ml  1)/(m  1) vertices and i = (l  1)/(m  1) internal vertices.

More Terminology  The level of a vertex v in a rooted tree is the length of the unique path from the root to this vertex v. The level of the root is defined to be zero.  The height of a rooted tree is the maximum of the levels of vertices. That is, the height is the length of the longest path from the root to any vertex.  A rooted m-ary tree of height h is balanced if all leaves are at levels h or h  1.

Example a b c d e f g h i j k l m n Level Vertices 0 a 1 b, j, k 2 c, e, f, l 3 d, g, i, m, n 4 h The height of this rooted tree is 4.

Example Balanced Not balanced

Balanced

10.2 Applications of Trees

Introduction  How should items in a list be stored so that an item can be easily located ?  What series of decisions should be made to find an object with a certain property in a collection of objects of a certain type ?  How should a set of characters be efficiently coded by bit strings ?

Binary Search Tree  簡介:二元搜尋樹 是一種二元樹。它可能是空的,若不是 空的,它具有下列特性: ( 1 ) 每一個元素有一鍵值,而且每一元素的鍵值都不相同, 即每一個鍵值都是唯一的。 ( 2 ) 在非空的左子樹上的鍵值,必小於在該子樹的根節點 中的鍵值。 ( 3 ) 在非空的右子樹上的鍵值,必大於在該子樹的根節點 中的鍵值。 ( 4 ) 左子樹和右子樹也都是二元搜尋樹。

Example1  Form a binary search tree for the words mathematic physics geography zoology meteorology geology psychology chemistry (using alphabetical order)

Constructing a Binary Search Tree  按照題目所給的字順序排,如題 Mathematics 就是 root  接下 Physic>Mathematics ,所以在 M 右下加一個 child  Geography<Mathematics ,所以在 M 左下加一個 child  Zoology>Mathematics 且 >Physics ,所以在 P 右下加 一個 child  Meteorology>Mathematics 但 <Physics ,所以在 P 左 下加一個 child

 Geology Geography ,所以在 Geography 的右下加一個 child  Psychology>Mathematics 且 >Physics 但 <Zoology 所 以在 Z 左下加一個 child  Chemistry<Mathematics 且 <Geography ,所以在 Geography 的左下加一個 child

Huffman Codes  簡介: Huffman 編制程式是試圖減少相當數量位元必需代 表標誌串的一個統計技術。  修造 Huffman 樹 ( 1 ) 選擇二個 parentless 結點以最低的可能性。 ( 2 ) 創造是二個最低的可能性結點的父母的一個新結點。 ( 3 ) 分配新結點可能性相等與它的孩子的可能性的總和。 ( 4 ) 重覆步驟 1 直到有只一個 parentless 結點剩下

Example 5  Use Huffman coding to encode the fallowing symbols with the frequencies listed: A:0.08, B:0.10, C:0.12, D:0.15, E:0.20, F:0.35. What is the average number of bits used to encode a character ?

Example 5  於題目中找尋最小兩點 →A:0.08 和 B:0.10(A 於右下 B 於左下 ∵ B>A)  接著把 A+B 視為新的一點 0.18 ,再找最小兩點 →C:0.12 和 D:0.15 如同 AB 方法接起來  C+D 也視為新的一點 0.27 再比大小,之後依此方法作完全 部的點  而全圖於右下角的支線都為 1, 左下角都之線都為 0  因此 A by 111,B by 110,C by 011,D by 010, E by 10, F by 00.  So the average number of bits used to encode a symbol using this encoding is 3×0.08+3×0.10+3×0.12+3×0.15+2×0.20+2×0.35=2.45

9.3Tree Traversal

Universal address system We will describe one way to order totally the vertices of an ordered rooted tree. To produce this ordering, we must first label all the vertices. We do this recursively : 1. Label the root with the integer 0. Then label its k children (at label 1) from left to right with 1,2,..., k. 2. For each vertex v at level n with label A, label its k v children, as they are drawn from left to right, with A.1,A.2,…A. k v.

Example 1  we display the labelings of the universal address system next to the vertices in the ordered rooted tree shown in Figure 1. Sol. The lexicographic ordering of the labelings is 0 < 1 < 1.1 < 1.2 < 1.3 < 2 < 3 < 3.1 < < < < < < < < 3.2 <4 < 4.1 < 5 < 5.1 < < 5.2 < 5.3

Def. 1  Let T be an order rooted tree with root r. If T consists only of r, then r is the preorder traversal of T. Otherwise, suppose that T 1, T 2, …, T n are the subtree at r from left to right in T. The preorder traversal begins by visiting r. It continues by traversing T 1 in preorder, then T 2 in preorder, and so on, until T n is traversed in preorder.

Example 2  In which order does a preorder traversal visit the vertices in the ordered rooted tree T shown below. a b c d e f g hi j k lm nop

a bcdef g hi j k l m nop aknop f cdglmhijbe The preorder traversal of T is a, b, e, j, k, n, o, p, f, c, d, g, l, m, h, i.

 Let T be an ordered rooted tree with root r. If T consists Only of r, then r is the inorder traversal of T. Otherwise, suppose that T 1, T 2, …, T n are the subtree at r from left to right in T. The inorder traversal begins by traversing T 1 in inorder, then visiting r. It continues by traversing T 2 in inorder, then T 3 in inorder,…, and Finally T n in inorder. Def. 2

Example 3 In which order does a inorder traversal visit the vertices in the ordered rooted tree T shown below. a b c d e f g hi j k lm nop

a b c d f g hi lm e j k nop a b cdf g h i l m ejk nop The preorder traversal of T is a, b, e, j, k, n, o, p, f, c, d, g, l, m, h, i.

 Let T be an ordered rooted tree with root r. If T Consists only of r, then r is the postrder traversal of T. Otherwise, suppose that T 1, T 2, …, T n are the subtreesat r from left to right in T. The postorder traversal begins by traversing T 1 in postorder, then T 2 in inorder, then T 3 in inorder,…, and ends by visiting r. Def. 3

Example 4 a b c d e f g hi j k lm nop In which order does a postorder traversal visit the vertices in the ordered rooted tree T shown below.

a b c d f g hi lm e j k nop a b cdf g h i l m ejk nop The preorder traversal of T is a, b, e, j, k, n, o, p, f, c, d, g, l, m, h, i.

Infix, Prefix, and Postfix notation Example 5  what is the ordered rooted tree that represents the expression((x+y)↑2)+((x-4)/3)?

+ xy x _ 4 ↑ + 2 xy x _ 4 3 / ↑ + 2 xy x _ 4 3 / +

↑ + 2 xy x _ 4 3 / + Example 6 what is the prefix from for ((x+y)↑2)+((x-4)/3)? Example 8 what is the postfix from for ((x+y)↑2)+((x-4)/3)? This produces the prefix expression : +↑+ x y 2 / - x 4 3 This produces the postefix expression : x y + 2 ↑ x / +

+ - * / ↑ * / * Example 7 what is the value of the prefix expression + - * / ↑ ?

7 2 3 * - 4 ↑ 9 3 / ↑ 9 3 / ↑ 9 3 / / Example 9 what is the value of the postfix expression * - 4 ↑9 3 / + ?

Example 10 Find the ordered rooted tree representing the compound proposition ( ┐ (p ^ q)) (┐p ˇ ┐q). Then use this rooted tree to find the prefix, postfix and infix firms of this expression. ^ pq ┐┐ pq ^ pq ┐ ┐┐ pq ˇ ^ pq ┐ ┐┐ pq ˇ preorder : ┐ ^ p q ˇ ┐p ┐q postorder : p q ^ ┐p ┐q ˇ inorder : (( ┐ (p ^ q)) ((┐p) ˇ (┐q)))

10.4 Spanning Trees (§9.4)  Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G.  Spanning Tree of a graph is not unique.

Theorem  A simple graph is connected if and only if it has a spanning tree.  Pf: Suppose that a simple graph G has a spanning tree T. T contains every vertex of G. There is a path in T between any two of its vertices. Thus there is a path in G between any two of its vertices. Hence, G is connected. Suppose that G is connected. If G is not a tree, it must contain a simple circuit. Removing an edge from this circuit obtains a subgraph of G, say G’. If G’ is a tree, than it is a spanning tree of G. Otherwise, we continue to remove edge from a circuit until we get a tree subgraph. This tree is a spanning tree of G.

Depth-First Search  Arbitrary choose a vertex as a root.  Successively adding vertices and edges where each new edge is incident with the last vertex in the path and a vertex not already in the path. Let this path as long as possible.  Move back to the next to last vertex in the path. a b c d e f g h ij k f e c d a b g h k j i

Algorithm: Depth-First Search procedure DFS(G; connected graph with vertices v 1, v 2, …, v n ) T := tree consisting only of the vertex v i visit(v i ) procedure visit(v: vertex of G) for each vertex w adjacent to v and not yet in T begin add vertex w and edge {v, w} to T visit(w) end The procedure DFS constructs a spanning tree using O(e), or O(n 2 ). DFS is also called backtracking, since the algorithm returns to vertices previously visited to add paths.

Example  How can backtracking be used to decide whether a given graph can be colored using 3 colors? a b c de a 1 b abcde Spanning Tree 2 cc d 1 3 e no way 3 d1 e3 Done

Breadth-First Search  Arbitrary choose a root.  Add all edges (and vertices) incident to this vertex. Order these vertices (in level 1) arbitrarily.  Continue this step for the vertices we obtaining in previous step as long as it does not produce a simple circuit till all vertices have been added. abc d e f g h i j k l m f ec i e j g b d l a h k m

Algorithm: Breadth-First Search procedure BFS(G; connected graph with vertices v 1, v 2, …, v n ) T := tree consisting only of the vertex v i L := empty list put v 1 in the list L of unprocessed vertices while L is not empty begin remove the first vertex, v, from L for each neighbor w of v if w is not in L and not in T then begin add w to the end of the list L add w and edge {v, w} to T end The procedure BFS constructs a spanning tree using O(e), or O(n 2 ).

DFS in Directed Graphs abcd e f g h ijkl a b c g f e d h l k j ii The output of DFS of a directed graph is not a tree, but a spanning forest.

10.5 Minimum Spanning Trees  A minimum spanning tree in a (weighted) connected graph is a spanning tree that has the smallest possible sum of weights of its edges.  The first algorithm was given by Robert Prim in Choose any edge with smallest weight. Successively add to the tree edges of minimum weight that are incident to the vertex already in the tree and not forming a simple circuit. Stop when n  1 edges have been added.

Algorithm Prim’s Algorithm procedure Prim(G: weighted connected undirected graph with n vertices) T := a minimum-weight edge for i := 1 to n  2 begin e := an edge of minimum weight incident to a vertex in T and not forming a simple circuit in T if added to T T := T with e added end (T is a minimum spanning tree of G)

Example San Francisco Chicago New York Atlanta Denver $2000 $1200 $1000 $2200 $900 $1400 $1300 $800 $700 $ (Chicago, Atlanta) 800 (Atlanta, New York) 900 (Denver, San Francisco) 1200 (San Francisco, Chicago) Total cost = $3600 Chicago AtlantaS F New YorkDenver

Example a bcd e f g h i j kl (c, d) 1 (b, f) 1 (k, l) 2 (c, g) 2 (a, b) 2 (f, j) 3 (b, c) 3 (a, e) 3 (i, j) 3 (g, h) 3 (h, l) Total = 24

Algorithm Kruskal’s Algorithm procedure Kruskal(G: weighted connected undirected graph with n vertices) T := empty tree for i := 1 to n  1 begin e := an edge in G with smallest weight that does not form a simple circuit when added to T T := T with e added end (T is a minimum spanning tree of G)

Example San Francisco Chicago New York Atlanta Denver $2000 $1200 $1000 $2200 $900 $1400 $1300 $800 $700 $ (Chicago, Atlanta) 800 (Atlanta, New York) 900 (Denver, San Francisco) 1200 (San Francisco, Chicago) Total cost = $3600

Example a bcd e f g h i j kl (c, d) 1 (b, f) 1 (k, l) 2 (a, b) 2 (c, g) 2 (f, j) 3 (b, c) 3 (g, h) 3 (a, e) 3 (h, l) 3 (i, j) Total = 24