SlideShare a Scribd company logo
1 of 22
Download to read offline
Discrete Mathematics
Trees
H. Turgut Uyar Ayşegül Gençata Emre Harmancı
2007
Content
Trees
Introduction
Spanning Tree
Rooted Trees
Introduction
Operation Tree
m-ary Trees
Tree
Definition
tree:
Graph G is called a tree if G is connected and contains no cycles.
I Graph whose connected components are trees: forest
Tree Theorems
Theorem
There is exactly one path between a node pair in a tree.
I There is a path because the tree is connected.
I If there were more than one path:
Tree Theorems
Theorem
The following statements are equivalent for a loop-free undirected
graph G(V , E) and |V | ≥ 2:
1. G is a tree (is connected and has no cycles.)
2. there is exactly one path between each node pair.
3. G is connected, but if an edge is removed it becomes
disconnected.
4. G does not have a cycle, but if an edge is added between any
two nodes a cycle is formed.
I proof method: 1 ⇒ 2 ⇒ 3 ⇒ 4 ⇒ 1
Tree Theorems
Theorem
The following statements are equivalent for a loop-free undirected
graph T(V , E):
1. T is a tree.
2. T is connected, and |V | = |E| + 1
3. T contains no cycles, and |V | = |E| + 1
Tree Theorems
Theorem
For every tree T(V , E), if |V | ≥ 2, then T has at least two
pendant vertices.
Proof.
I 2|E| =
P
v∈V dv
I Assume there is one vertex of degree 1:
⇒ 2|E| ≥ 2(|V | − 1) + 1
⇒ 2|E| ≥ 2|V | − 1
⇒ |E| ≥ |V | − 1
2 > |V | − 1 contradiction
Spanning Tree
Definition
spanning tree:
A subgraph T of a graph G is called a spanning tree of G, if T is a
tree and T includes all vertices of G.
Definition
minimum spanning tree:
A spanning tree for which the sum of the edge weights is minimum.
Kruskal’s Algorithm
Kruskal’s algorithm
1. Set the counter i ← 1, select e1 ∈ E, where wt(e1) is
minimum
2. For 1 ≤ i ≤ n − 2:
if edges e1, e2, . . . , ei have been selected, select ei+1 from the
remaining edges in G so that:
I wt(ei+1) is minimum
I The subgraph determined by e1, e2, . . . , ei , ei+1 contains no
cycles.
3. Replace i ← i + 1
I If i = n − 1 the subgraph with edges e1, e2, . . . , en−1 is an
optimal spanning tree of G.
I If i < n − 1 return to step 2.
Rooted Tree
I The tree T is a directed tree, if all edges of T are directed.
I T is called a rooted tree if there is a unique vertex r, called
the root, with indegree of 0, and for all other vertices v the
indegree is 1.
I All vertices with outdegree 0 are called leaf.
I All other vertices are called branch node or internal node.
Node Level
Definition
level:
distance from root
I parent: preceeding node
I child: succeeding node
Example
Example
I root: r
I leaves: x y z u v
I internal nodes: p n t s q w
I parent of y : w
children of w : y and z
Binary Rooted Trees
I binary rooted tree: Every node has at most 2 children
I complete binary rooted tree: Every node has 0 or 2 children
Operation tree
I Mathematical operations can be represented by trees.
I root and internal nodes contain operators
I the leaves contain variables/constants
Traversal of Operation Tree
1. inorder: left sub-tree, root, right sub-tree
2. preorder: root, left sub-tree, right sub-tree
3. postorder:left sub-tree, right sub-tree, root
I Changing operator precedence requires parantheses in inorder
notation.
Example
Example
t +
u · v
w + x − yz
Example of preorder traversal
Example
+ t / ∗ u v + w − x ↑ y z
Example of inorder traversal
Example
t + u ∗ v / w + x − y ↑ z
Example of postorder traversal
Example
t u v ∗ w x y z ↑ − + / +
m-ary Tree
Definition
m-ary tree:
The outdegree of all vertices, except leaves, is m.
m-ary Trees
Theorem
In an m-ary tree:
I number of nodes n
I number of leaves l
I number of internal nodes i
I n = m · i + 1
I l = n − i = m · i + 1 − i = (m − 1) · i + 1
I i = l−1
m−1
Example
Example
How many matches are played in a tennis tournament of 27
players?
I a leaf for each player: l = 27
I an internal node for each match: m = 2
I number of matches: i = l−1
m−1 = 27−1
2−1 = 26

More Related Content

Similar to trees.pdf

Mithfh lecturenotes 9
Mithfh lecturenotes 9Mithfh lecturenotes 9
Mithfh lecturenotes 9
Praveen Kumar
 
Treewidth and Applications
Treewidth and ApplicationsTreewidth and Applications
Treewidth and Applications
ASPAK2014
 
Introduction To Matrix
Introduction To MatrixIntroduction To Matrix
Introduction To Matrix
Annie Koh
 
Matroid Basics
Matroid BasicsMatroid Basics
Matroid Basics
ASPAK2014
 
M1 unit i-jntuworld
M1 unit i-jntuworldM1 unit i-jntuworld
M1 unit i-jntuworld
mrecedu
 
Basic Terminologies of Tree and Tree Traversal methods.pptx
Basic Terminologies of Tree and Tree Traversal methods.pptxBasic Terminologies of Tree and Tree Traversal methods.pptx
Basic Terminologies of Tree and Tree Traversal methods.pptx
22001003058
 

Similar to trees.pdf (20)

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptx
 
Use of the Tree.
Use of the Tree.Use of the Tree.
Use of the Tree.
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
 
Mithfh lecturenotes 9
Mithfh lecturenotes 9Mithfh lecturenotes 9
Mithfh lecturenotes 9
 
50120140501010
5012014050101050120140501010
50120140501010
 
Treewidth and Applications
Treewidth and ApplicationsTreewidth and Applications
Treewidth and Applications
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
M ary-tree
M ary-treeM ary-tree
M ary-tree
 
Trees (slides)
Trees (slides)Trees (slides)
Trees (slides)
 
trees.ppt
trees.ppttrees.ppt
trees.ppt
 
Introduction To Matrix
Introduction To MatrixIntroduction To Matrix
Introduction To Matrix
 
Matroid Basics
Matroid BasicsMatroid Basics
Matroid Basics
 
M1 unit i-jntuworld
M1 unit i-jntuworldM1 unit i-jntuworld
M1 unit i-jntuworld
 
INDEPENDENT AND CONNECTED DOMINATION NUMBER IN MIDDLE AND LINE GRAPHS
INDEPENDENT AND CONNECTED DOMINATION NUMBER IN MIDDLE AND LINE GRAPHSINDEPENDENT AND CONNECTED DOMINATION NUMBER IN MIDDLE AND LINE GRAPHS
INDEPENDENT AND CONNECTED DOMINATION NUMBER IN MIDDLE AND LINE GRAPHS
 
Characterization of trees with equal total edge domination and double edge do...
Characterization of trees with equal total edge domination and double edge do...Characterization of trees with equal total edge domination and double edge do...
Characterization of trees with equal total edge domination and double edge do...
 
trees-and-forest.pdf
trees-and-forest.pdftrees-and-forest.pdf
trees-and-forest.pdf
 
Euler and hamilton paths
Euler and hamilton pathsEuler and hamilton paths
Euler and hamilton paths
 
Basic Terminologies of Tree and Tree Traversal methods.pptx
Basic Terminologies of Tree and Tree Traversal methods.pptxBasic Terminologies of Tree and Tree Traversal methods.pptx
Basic Terminologies of Tree and Tree Traversal methods.pptx
 
Special Elements of a Ternary Semiring
Special Elements of a Ternary SemiringSpecial Elements of a Ternary Semiring
Special Elements of a Ternary Semiring
 
Farhana shaikh webinar_treesindiscretestructure
Farhana shaikh webinar_treesindiscretestructureFarhana shaikh webinar_treesindiscretestructure
Farhana shaikh webinar_treesindiscretestructure
 

Recently uploaded

一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
c3384a92eb32
 
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
AshwaniAnuragi1
 
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
A
 

Recently uploaded (20)

Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
Databricks Generative AI FoundationCertified.pdf
Databricks Generative AI FoundationCertified.pdfDatabricks Generative AI FoundationCertified.pdf
Databricks Generative AI FoundationCertified.pdf
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/Footing
 
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdf
 
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
 
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 

trees.pdf

  • 1. Discrete Mathematics Trees H. Turgut Uyar Ayşegül Gençata Emre Harmancı 2007
  • 3. Tree Definition tree: Graph G is called a tree if G is connected and contains no cycles. I Graph whose connected components are trees: forest
  • 4. Tree Theorems Theorem There is exactly one path between a node pair in a tree. I There is a path because the tree is connected. I If there were more than one path:
  • 5. Tree Theorems Theorem The following statements are equivalent for a loop-free undirected graph G(V , E) and |V | ≥ 2: 1. G is a tree (is connected and has no cycles.) 2. there is exactly one path between each node pair. 3. G is connected, but if an edge is removed it becomes disconnected. 4. G does not have a cycle, but if an edge is added between any two nodes a cycle is formed. I proof method: 1 ⇒ 2 ⇒ 3 ⇒ 4 ⇒ 1
  • 6. Tree Theorems Theorem The following statements are equivalent for a loop-free undirected graph T(V , E): 1. T is a tree. 2. T is connected, and |V | = |E| + 1 3. T contains no cycles, and |V | = |E| + 1
  • 7. Tree Theorems Theorem For every tree T(V , E), if |V | ≥ 2, then T has at least two pendant vertices. Proof. I 2|E| = P v∈V dv I Assume there is one vertex of degree 1: ⇒ 2|E| ≥ 2(|V | − 1) + 1 ⇒ 2|E| ≥ 2|V | − 1 ⇒ |E| ≥ |V | − 1 2 > |V | − 1 contradiction
  • 8. Spanning Tree Definition spanning tree: A subgraph T of a graph G is called a spanning tree of G, if T is a tree and T includes all vertices of G. Definition minimum spanning tree: A spanning tree for which the sum of the edge weights is minimum.
  • 9. Kruskal’s Algorithm Kruskal’s algorithm 1. Set the counter i ← 1, select e1 ∈ E, where wt(e1) is minimum 2. For 1 ≤ i ≤ n − 2: if edges e1, e2, . . . , ei have been selected, select ei+1 from the remaining edges in G so that: I wt(ei+1) is minimum I The subgraph determined by e1, e2, . . . , ei , ei+1 contains no cycles. 3. Replace i ← i + 1 I If i = n − 1 the subgraph with edges e1, e2, . . . , en−1 is an optimal spanning tree of G. I If i < n − 1 return to step 2.
  • 10. Rooted Tree I The tree T is a directed tree, if all edges of T are directed. I T is called a rooted tree if there is a unique vertex r, called the root, with indegree of 0, and for all other vertices v the indegree is 1. I All vertices with outdegree 0 are called leaf. I All other vertices are called branch node or internal node.
  • 11. Node Level Definition level: distance from root I parent: preceeding node I child: succeeding node
  • 12. Example Example I root: r I leaves: x y z u v I internal nodes: p n t s q w I parent of y : w children of w : y and z
  • 13. Binary Rooted Trees I binary rooted tree: Every node has at most 2 children I complete binary rooted tree: Every node has 0 or 2 children
  • 14. Operation tree I Mathematical operations can be represented by trees. I root and internal nodes contain operators I the leaves contain variables/constants
  • 15. Traversal of Operation Tree 1. inorder: left sub-tree, root, right sub-tree 2. preorder: root, left sub-tree, right sub-tree 3. postorder:left sub-tree, right sub-tree, root I Changing operator precedence requires parantheses in inorder notation.
  • 16. Example Example t + u · v w + x − yz
  • 17. Example of preorder traversal Example + t / ∗ u v + w − x ↑ y z
  • 18. Example of inorder traversal Example t + u ∗ v / w + x − y ↑ z
  • 19. Example of postorder traversal Example t u v ∗ w x y z ↑ − + / +
  • 20. m-ary Tree Definition m-ary tree: The outdegree of all vertices, except leaves, is m.
  • 21. m-ary Trees Theorem In an m-ary tree: I number of nodes n I number of leaves l I number of internal nodes i I n = m · i + 1 I l = n − i = m · i + 1 − i = (m − 1) · i + 1 I i = l−1 m−1
  • 22. Example Example How many matches are played in a tennis tournament of 27 players? I a leaf for each player: l = 27 I an internal node for each match: m = 2 I number of matches: i = l−1 m−1 = 27−1 2−1 = 26