Minimum Cost Spanning Tree
Minimum Cost Spanning Tree
Tree
branch
leaf
DAA 214 2
Trees (Contd.)
DAA 214 3
Tree Terminology
1. Root
2. Node
3. Parent
4. Child
5. Leaf
6. Siblings
7. Degree of a node
8. Depth of a node
9. Height of a tree
DAA 214 4
Tree Terminology (Contd.)
• Root:It is node with no parent.
• Node: It is a vertex of the tree where a data element is stored.
• Parent : It is a single node that directly precedes a node.
• Child : It is a node that directly follows a node.
• Leaf : It is a node with no children,Items at the very bottom of a
hierarchical tree structure.
• Siblings: The nodes which share same parent
• Degree of an node:The number of children it has
• Depth:The depth of x in T is the length of the path from the root r to
a node x.
• Height:The largest depth of any node in a tree is the height.
DAA 214 5
Tree Terminology (Contd.)
DAA 214 6
Binary tree
• A binary tree is a tree structure in which each node has at most two
children.
• Each element in a Binary Tree has degree 2.
• Examples
DAA 214 7
Full Binary Tree
DAA 214 8
Complete Binary Tree
• It is a Binary tree where each node is either a leaf or has degree 2.
• Completely filled, except possibly for the bottom level and level above
• Each level is filled from left to right.
• All nodes at the lowest level are as far to the left as possible
• Full binary tree is also a complete binary tree.
DAA 214 9
Examples of Complete Binary Trees
14 14
12 7 12 7
10 8 6 10 8 6 5
4 3
DAA 214 12
DAA 214 13
Heap Tree.
DAA 214 14
DAA 214 15
What is a Spanning Tree?
• Tree : A connected undirected graph that contains no cycles is called a
tree.
• Spanning Tree : A spanning tree of a graph G is a subgraph of G that is a
tree and contains all the vertices of G.
A B
A B A B
C
C C
D
D D
E
E E
16
Properties of spanning Tree
• The spanning tree of a n –vertex undirected graph has exactly n-1 edges.
• Spanning tree has no cycles
• It Connects all vertexes in the graph.
• Input: A connected, undirected graph G = (V, E)
with weight function w : E → R.
• Output: A spanning tree T —a tree that connects
all vertices — of minimum weight:
w(T ) w(u, v)
( u , v )T
17
What is a Minimum Cost Spanning Tree?
• Minimum Cost Spanning Tree is the tree amongst all spanning trees
with the smallest cost
6 B A B
A
1 1 1
1
3 C 2 3 C 2
4 D
D
E
5 E
19