Tree and Its Terminologies
Tree and Its Terminologies
Terminologies
Tree: Collection of data (Node) which is
organized in hierarchical structure
Hamza Ashraf (BCSM-F19-368) recursively.
Muhammad Usama (BCSM-F19-
474)
Table of contents
01 02
Tree Defination Applications
Non-linear data structure 3 Real life Applications of
organizes data in tree used nowadays
hierarchical structure
03 04
Terminologies Examples
15 Terminologies of Tree 2 Examples of each
Terminology
What is a Tree?
1) A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists of a
distinguished node, r, called the root, and zero or more nonempty (sub)trees T1, T2, ... , Tk, each
of whose roots are connected by a directed edge from r. (DSAA by Mark Allen Weiss)
page 121.
1) It consists of an ordered set of linked nodes in a connected graph, in which each node has at
most one parent node, and zero or more children nodes with a specific order. (DSA By John
Bullinaria) page31.
Applications Of Tree
7. Internal
6. Leaf 8. Degree 9. Level 10. Height
Nodes
Edges
● The connecting link between any two nodes is
called as an edge.
● In a tree with n number of nodes, there are
exactly (n-1) number of edges.
Edges (Examples)
Parent
● The node which has a branch from it to any
other node is called as a parent node.
● In other words, the node which has one or more
children is called as a parent node.
● In a tree, a parent node can have any number of
child nodes.
Parent (Examples)
Child
Siblings
● Nodes which belong to the same parent are
called as siblings.
● In other words, nodes with the same parent are
sibling nodes.
Siblings (Examples)
Leaf
● The node which does not have any child is
called as a leaf node.
● Leaf nodes are also called as external nodes or
terminal nodes.
Leaf (Examples)
Internal
Nodes
● The node which has at least one child is called
as an internal node.
● Internal nodes are also called as non-terminal
nodes.
● Every non-leaf node is an internal node.
Internal Nodes (Examples)
External
Nodes
● The node which has not any child is called as
an external node.
● External nodes are also called as terminal
nodes.
● Every leaf node is an External node.
External Nodes (Examples)
Degree
● Degree of a node is the total number of children
of that node.
● Degree of a tree is the highest degree of a node
among all the nodes in the tree.
Degree (Examples)
Level
● In a tree, each step from top to bottom is called
as level of a tree.
● The level count starts with 0 and increments by
1 at each level or step.
Level (Examples)
Level Level
0 0
Level Level
1 1
Level Level
2 2
Level
3 Level
3
It has level from 0 to 3 It has level from 0 to 3
Terminologies
Height
● Total number of edges that lies on the longest
path from any leaf node to a particular node is
called as height of that node.
● Height of a tree is the height of root node.
● Height of all leaf nodes = 0
Height (Examples)
Path
● In a tree data structure, the sequence of Nodes
and Edges from one node to another node is
called as PATH between that two Nodes.
● Length of a Path is total number of nodes in
that path.
Path (Examples)
Sub Tree
● In a tree, each child from a node forms a
subtree recursively.
● Every child node forms a subtree on its parent
node.
Sub-tree (Examples)
Forest
● A forest is a set of disjoint trees.
● Forest in data structure Creating forest from a
tree.
● You can create a forest by cutting the root of a
tree
Forest (Examples)