TREE Terminologies
By,
Dr. Gopika S
Department of CS
Kristu Jayanti College , Bengaluru
Trees
Tree is a finite set of vertices that has a vertex called
as root and remaining vertices are collection of
subtrees.
Dr. Gopika S , KJC , Bengaluru 2
Dr. Gopika S , KJC , Bengaluru 3
Dr. Gopika S , KJC , Bengaluru 4
5
Node Degree
• Node degree is the number of children it has
Dr. Gopika S , KJC , Bengaluru
6
Tree Degree
• Tree degree is the maximum of node degrees
tree degree = 3
Dr. Gopika S , KJC , Bengaluru
subtree
Tree Terminology
• Root: node without parent (A)
• Siblings: nodes share the same parent
• Internal node: node with at least one
child (A, B, C, F)
• External node (leaf ): node without
children (E, I, J, K, G, H, D)
• Ancestors of a node: parent,
grandparent, grand-grandparent, etc.
• Descendant of a node: child,
grandchild, grand-grandchild, etc.
• Depth of a node: number of ancestors
• Height of a tree: maximum depth of
any node (3)
• Degree of a node: the number of its
children
• Degree of a tree: the maximum
number of its node.
A
B D
C
G H
E F
I J K
Subtree: tree consisting of a
node and its descendants
Dr. Gopika S , KJC , Bengaluru 7
• Path: traversal from node to node along the edges that results in
a sequence
• Root: node at the top of the tree
• Parent: any node, except root has exactly one edge running
upward to another node. The node above it is called parent.
• Child: any node may have one or more lines running downward
to other nodes. Nodes below are children.
• Leaf: a node that has no children
• Sub tree: any node can be considered to be the root of a subtree,
which consists of its children and its children's children and so
on.
• Visiting: a node is visited when program control arrives at the
node, usually for processing.
• Traversing: to traverse a tree means to visit all the nodes in some
specified order.
• Levels: the level of a particular node refers to how many
generations the node is from the root. Root is assumed to be
level 0.
Dr. Gopika S , KJC , Bengaluru 8
• Some Terminology
– node: the item of information plus the branches to each
node.
– degree: the number of subtrees of a node
– degree of a tree: the maximum of the degree of the
nodes in the tree.
– terminal nodes (or leaf): nodes that have degree zero
– nonterminal nodes: nodes that don’t belong to terminal
nodes.
– children: the roots of the subtrees of a node X are the
children of X
– parent: X is the parent of its children.
Dr. Gopika S , KJC , Bengaluru 9
–siblings: children of the same parent are said to
be siblings.
–Ancestors of a node: all the nodes along the
path from the root to that node.
–The level of a node: defined by letting the root
be at level one. If a node is at level l, then it
children are at level l+1.
–Height (or depth): the maximum level of any
node in the tree
Dr. Gopika S , KJC , Bengaluru 10
• Example
A is the root node
B is the parent of D and E
C is the sibling of B
D and E are the children of B
D, E, F, G, I are external nodes, or leaves
A, B, C, H are internal nodes
The level of E is 3
The height (depth) of the tree is 4
The degree of node B is 2
The degree of the tree is 3
The ancestors of node I is A, C, H
The descendants of node C is F, G, H, I
A
B C
H
I
D E F G
Level
1
2
3
4
Property: (# edges) = (#nodes) - 1
Dr. Gopika S , KJC , Bengaluru 11
Thank you
Dr. Gopika S , KJC , Bengaluru 12

Introduction to Tree .pptx

  • 1.
    TREE Terminologies By, Dr. GopikaS Department of CS Kristu Jayanti College , Bengaluru
  • 2.
    Trees Tree is afinite set of vertices that has a vertex called as root and remaining vertices are collection of subtrees. Dr. Gopika S , KJC , Bengaluru 2
  • 3.
    Dr. Gopika S, KJC , Bengaluru 3
  • 4.
    Dr. Gopika S, KJC , Bengaluru 4
  • 5.
    5 Node Degree • Nodedegree is the number of children it has Dr. Gopika S , KJC , Bengaluru
  • 6.
    6 Tree Degree • Treedegree is the maximum of node degrees tree degree = 3 Dr. Gopika S , KJC , Bengaluru
  • 7.
    subtree Tree Terminology • Root:node without parent (A) • Siblings: nodes share the same parent • Internal node: node with at least one child (A, B, C, F) • External node (leaf ): node without children (E, I, J, K, G, H, D) • Ancestors of a node: parent, grandparent, grand-grandparent, etc. • Descendant of a node: child, grandchild, grand-grandchild, etc. • Depth of a node: number of ancestors • Height of a tree: maximum depth of any node (3) • Degree of a node: the number of its children • Degree of a tree: the maximum number of its node. A B D C G H E F I J K Subtree: tree consisting of a node and its descendants Dr. Gopika S , KJC , Bengaluru 7
  • 8.
    • Path: traversalfrom node to node along the edges that results in a sequence • Root: node at the top of the tree • Parent: any node, except root has exactly one edge running upward to another node. The node above it is called parent. • Child: any node may have one or more lines running downward to other nodes. Nodes below are children. • Leaf: a node that has no children • Sub tree: any node can be considered to be the root of a subtree, which consists of its children and its children's children and so on. • Visiting: a node is visited when program control arrives at the node, usually for processing. • Traversing: to traverse a tree means to visit all the nodes in some specified order. • Levels: the level of a particular node refers to how many generations the node is from the root. Root is assumed to be level 0. Dr. Gopika S , KJC , Bengaluru 8
  • 9.
    • Some Terminology –node: the item of information plus the branches to each node. – degree: the number of subtrees of a node – degree of a tree: the maximum of the degree of the nodes in the tree. – terminal nodes (or leaf): nodes that have degree zero – nonterminal nodes: nodes that don’t belong to terminal nodes. – children: the roots of the subtrees of a node X are the children of X – parent: X is the parent of its children. Dr. Gopika S , KJC , Bengaluru 9
  • 10.
    –siblings: children ofthe same parent are said to be siblings. –Ancestors of a node: all the nodes along the path from the root to that node. –The level of a node: defined by letting the root be at level one. If a node is at level l, then it children are at level l+1. –Height (or depth): the maximum level of any node in the tree Dr. Gopika S , KJC , Bengaluru 10
  • 11.
    • Example A isthe root node B is the parent of D and E C is the sibling of B D and E are the children of B D, E, F, G, I are external nodes, or leaves A, B, C, H are internal nodes The level of E is 3 The height (depth) of the tree is 4 The degree of node B is 2 The degree of the tree is 3 The ancestors of node I is A, C, H The descendants of node C is F, G, H, I A B C H I D E F G Level 1 2 3 4 Property: (# edges) = (#nodes) - 1 Dr. Gopika S , KJC , Bengaluru 11
  • 12.
    Thank you Dr. GopikaS , KJC , Bengaluru 12