Trees
Trees
TREES
Tree
Is a mathematical structure that is a
special kind of graph which has the
following properties:
• undirected
• Connected
• acyclic
• bridge
• components
• forest
Examples of Trees with
Corresponding Number of Vertices
and Edges
Trees on Chemical Structure
H H
H C H H C H
H H C H
H C H
H
Rooted Trees
• A tree is called a rooted tree if one vertex has been designated the
root.
• ROOT – usually refers to a top – most vertex that extends downward
meaning each edge is simply directed away from the root.
• FREE ROOT – a tree without any designated root.
Rooted Trees
Terms to remember
• Level (or depth) – in a rooted tree, the vertex is its distance from the
root.
• Height – height of a tree is the number of vertices or edges traversed
from the root to get the most distant vertex.
• Parent – is the vertex connected to it on the path to the root.
• Child (or offspring)- vertex d is a vertex of which a is a parent.
• Sibling – is a vertex which shares the same parent.
Continuation
• Descendant – is a vertex which is further away from the root than
some other vertex.
• Ancestors – is any vertex between a given vertex and the root.
• Terminal vertex (or leaf) – is a vertex with no children.
• Internal vertex (or branch vertex) – is a vertex that has at least one
child.
• Sub – tree – a smaller portion of a tree starting at some specifies
vertex.
Terms
a c
b
e
d f g h
i
M-ary
• Complete
• Full
• Balanced
Traversal
r • Breadth-first
• Inorder
a b • Preorder
• Postorder
c d e f
Traversal
r • Breadth-first
• Inorder
a b • Preorder
• Postorder
c d e f
Traversal
r • Breadth-first
• Inorder
a b • Preorder
• Postorder
c d e f
Traversal
r • Breadth-first
• Inorder
a b • Preorder
• Postorder
c d e f
• Spanning Tree – is a subgraph which is tree and contains all vertices of
the graph.
• Prim’s algorithm – developed by Robert Clay in 1957 which is a greedy
algorithm that determines a minimum spanning tree for a connected
weighted undirected graph.
• Kruskal’s algorithm – developed by Joseph Bernard Kruskal (1928-
2010).
• Dijkstra’s algorithm – developed by Edsger W. Dijkstra (1930 – 2002).
The algorithm is a graph search algorithm that determines the single –
source shortest – path problem for a graph producing a shortest path
tree.