Presentation Descrete Maths

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

PRESENTATION

SUBJECT:
• Discrete mathematics

Topic:
• Tree
Submitted to:
Members:
• Mam Iqra Ashraf
• Muhammad Adil(55)
• Ahsan(22)
Date:
• Muqeem Ansari(60)
• 15-01-2024
• Abdullah(59)
• Alladitta(25)
TREES
DEFINE:
A graph G is called tree if :
• G is connected
• G has no cycle

True False
TREES
Properties:
• There is one and only one path between every pair of vertices in a
tree.
• A tree with n-vertices n-1 edges.
ROOTED TREE

• Rooted Tree is a tree in which one vertex act


as a root.
BASIC TERMINOLOGY IN TREE
Parent:
The node which is predecessor of any node .
Child/Offspring:
Node which is descendent of any node.
Sibling:
Nodes which belong to same parent.
Leaf:
Nodes having no child
Internal Nodes:
Nodes other than leaf nodes or nodes having atleast one child.
BASIC TERMINOLOGY IN TREE
BASIC TERMINOLOGY IN TREE
Level:
Level of node is the distance of node from root node.
a. Root is at level “o”.
b. Children of root are at level “1”.
c. Children of level “1” nodes are at level “2”.
Height:
Height of a nodes is a no. of edges between the node and the farthest leave.
Depth:
Depth of a tree is no. of edges from node to the root node.
Root has depth zero.
BASIC TERMINOLOGY IN TREE
TYPE OF TREE
Binary tree:
• It is tree in which each node has almost two children.
TYPE OF TREE
Full/strict Binary tree:
• Internal nodes have exactly 2 child.
TYPE OF TREE
Complete Binary Tree:
• Exactly two child with leaf nodes at same level.
TYPE OF TREE
Almost complete Binary tree:

• Satisfy two condition:


• Last level must be strictly filled from left to right.
• All levels are completely filled except possibly
• the last level.
TYPE OF TREE
Sub Tree:
-Each child from the node form a subtree.
• -Every child node form a sub tree on its parent node.
• Subtree of a node is defined as a tree which is a child of a node.
The name emphasizes that everything which is a descendant of a
tree node is a tree too, and is a subset of the larger tree
TRAVERSAL TREE
• A traversal of tree is a process to traverse a tree in systematic way, so
each vertex visited exactly once.
Types of Traversal

• Pre-order

• Post-order

• In-order
Types of Traversal
Pre Order:

• Visit The root


• Traverse Left sub-tree in order.
• Traverse Right sub-tree in Preorder
Types of Traversal
Post-Order:

Left sub tree in post-order


Right tree in post-order
• Visit the root
Types of Traversal
In-order

• Traverse in-order left tree


• Visit the roots
• Traverse in-order right tree
EXAMPLES
• What are the left and right children of d in the binary tree T shown
in Figure 8(a) (where the order is that implied by the drawing)?
What are the left and right subtrees of c?
• Solution:
• The left child of d is f and the right child is g. We show the left and
right subtrees of c in Figures 8(b) and 8(c), respectively.
EXAMPLES
• Which of the rooted trees shown in Figure 14 are balanced?
Solution:
T1 is balanced, because all its leaves are at levels 3 and 4. However,
T2 is not balanced, because it has leaves at levels 2, 3, and 4. Finally, T3
is balanced, because all its leaves are at level 3.
EXAMPLES
Prove that a tree with n vertices has n-1
edges?
• Proof → We will prove this result by mathematical Induction
• Step-1:
obviously result is true for n=1, 2, 3 as:
when n=1 we have zero edge
we have n=2 one edge
we have n=3 two edges
• Step-II :
→ Let us suppose that result is true for n= K.
i.e. for n= k => e = K-1
• Step-III:
To Prove for n= K+1 => e = K
EXAMPLES
• In the rooted tree T (with root a) shown in Figure 5, find the parent of c, the
children of g, the siblings of h, all ancestors of e, all descendants of b, all
internal vertices, and all leaves. What is the subtree rooted at g?
• Solution:
• The parent of c is b. The children of g are h, i, and j . The siblings of h are i and j .
The ancestors of e are c, b, and a. The descendants of b are c, d, and e. The
internal vertices are a, b, c, g, h, and j . The leaves are d, e, f , i, k, l, and m. The
subtree rooted at g is shown in Figure 6.
EXAMPLES
• Are the rooted trees in Figure 7 full m-ary trees for some positive integer m?
• Solution: T1 is a full binary tree because each of its internal vertices has two
children. T2 is a full 3-ary tree because each of its internal vertices has three
children. In T3 each internal vertex has five children, so T3 is a full 5-ary tree. T4 is
not a full m-ary tree for any m because some of its internal vertices have two
children and others have three children.
EXAMPLES
• Answer these questions about the rooted tree illustrated.
• a) Which vertex is the root?
• b) Which vertices are internal?
• c) Which vertices are leaves?
• d) Which vertices are children of j?
• e) Which vertex is the parent of h?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy