SlideShare ist ein Scribd-Unternehmen logo
1 von 28
TREE
PRESENTED BY
SIMRAN KAUR
TREE
 A tree is the data structure that are based on
hierarchical tree structure with set of nodes
 It is an acyclic connected graph with one or
more children nodes and at most one root
node
TREE TERMINOLOGY
 NODE: Each data item in a tree
 ROOT: First or top data item in hierarchical
arrangement
 DEGREE OF A NODE: Number of subtrees of
a given node
 DEGREE OF A TREE: Maximum degree of a
node in a tree
 DEPTH OR HEIGHT: Maximum level number
of a node + 1(i.e., level number of farthest leaf
node of a tree + 1)
TREE TERMINOLOGY
 NON-TERMINAL NODE: Any node except
root node whose degree is not zero
 TERMINAL NODE OR LEAF NODES: Nodes
having zero
 FOREST: Set of disjoint trees
 PATH: Sequence of consecutive edges from
the source node to the destination node
BINARY TREE
 In this kind of tree, the maximum degree of
any node is at most 2
 A binary tree T is defined as a finite set of
elements such that T is empty (called NULL
tree or empty tree) and T contains a
distinguished Node R called the root of T and
the remaining nodes of T form an ordered pair
of disjoint binary trees 𝑇1, and 𝑇2
FULL BINARY TREE
 A binary tree in which all leaves are t the
same level or at the same depth and in which
every parent has exactly 0 or 2 children
COMPLETE BINARY TREE
A binary tree is one which have the following
properties:
i) Which can have 0, 1 or 2 nodes as a child
node
ii) In which first, we need to fill left node, then
right node in a level
iii) In which, we can start putting data item in
next level only when the previous level is
completely filled
PREORDER TREE
TRAVERSAL
 Process the root R
 Traverse the left subtree of R in preorder
 Traverse the right subtree of R in preorder
INORDER TREE
TRAVERSAL
 Traverse the left subtree of R in inorder
 Process the root R
 Traverse the right subtree of R in inorder
POSTORDER TREE
TRAVERSAL
 Traverse the left subtree of R in postorder
 Traverse the right subtree of R in postorder
 Process the root R
BREADTH FIRST TRAVERSAL
(BFT)
 The breadth first traversal of a tree visits the
nodes in the order of depth in the tree
 BFT first visits all the nodes at depth zero
(i.e., root), then all the nodes at depth one
and so on
 At each depth, the nodes are visited from left
to right
DEPTH FIRST TRAVERSAL
(DFT)
 Depth first traversal is an algorithm for
traversing or searching a tree, tree structure
or graph
 One starts at the root and explores as far as
possible along each branch before
backtracking
BINARY SEARCH TREE
A binary search tree, also called as an ordered
or sorted binary tree, has following properties:
i) The left subtree of a node contains only
nodes with keys less than the node’s key
ii) The right subtree of a node contains only
nodes with keys greater than the node’s key
iii) Both the left subtrees and right subtrees
must also be binary search trees
AVERAGE CASE PERFORMANCE
OF BST OPERATIONS
 Internal Path Length (IPL) of a binary tree is
the sum of the depths of its nodes.
 Average internal path length T(n) of binary
trees with n nodes is O(n log n)
 The average complexity to find or insert
operations is T(n) = O(log n)
AVL TREES
An AVL (Adelson-Velskii and Land) is a binary
tree with the following additional balance
properties:
i) For any node in the tree, the height of the
left and right subtrees can differ by atmost
ii) The height of an empty subtree is -1
AVL TREES
 An AVL is a binary search tree which has the
following properties:
i) The subtrees of every node differ in height
by atmost one
ii) Every subtree is an AVL tree
 Balance factor of a node = Height of left
subtree – Height of right subtree
GREEDY ALGORITHMS
 Greedy algorithms are simple and straight-
forward
 They are short sighted in their approach in the
sense they take decisions on the basis of
information at hand without worrying about
the effect of these decisions in the future
 They are used to solve optimization problems
FEASIBILITY
 A feasible set is promising, if it can be
extended to produce not merely as solution,
but an optimal solution to the problem
SPANNING TREE
 A spanning tree of a graph is any tree that
includes every vertex in the graph
 A spanning tree of a graph G is a subgraph of
G that is a tree and contains all vertices of G
 The number of spanning trees in the complete
graph 𝐾 𝑛 is 𝑛 𝑛−2
MINIMUM SPANNING TREE
 A Minimum Spanning Tree (MST) of a
weighted graph G is a spanning tree of G
whose edges sum is minimum weight
 There are two algorithms to find the minimum
spanning tree of an undirected weighted
graph
KRUSKAL’S ALGORITHM
 Kruskal’s algorithm is a Greedy algorithm
 In this algorithm, starts with each vertex being
its component. Repeatedly merges two
components into one by choosing the light
edge that connects them, that’s why, this
algorithm is edge based algorithm
KRUSKAL’S ALGORITHM
Let G = (V,E) is a connected, undirected,
weighted graph
 Scans the set of edges in increasing order by
weight. The edge is selected such that: i)
acyclicity should be maintained, ii) it should
be minimum weight, iii) when tree T contains
n-1 edges, also must terminate
 Uses a disjoint set of data structure to
determine whether an edge connects vertices
in different components
ANALYSIS OF KRUSKAL’S
ALGORITHM
The total time taken by this algorithm to find the
minimum spanning tree is O(E 𝑙𝑜𝑔2 E) (if edges
are already sorted)
But the time complexity, if edges are not sorted
is O(E 𝑙𝑜𝑔2 V)
PRIM’S ALGORITHM
 Prim’s algorithm is based on a generic
minimum spanning tree algorithm
 The idea of Prim’s algorithm is to find the
shortest path in a given graph
 The Prim’s algorithm has the property that the
edges in the set A always form a single
connected tree
PRIM’S ALGORITHM
We begin with some vertex V in a given graph G
= (V,E), defining the initial set of vertices A.
Then, in each iteration, we choose a minimum
weight edge (u,v), connecting a vertex v in the
set A to the vertex u outside of set A. Then,
vertex u is brought into A. This tree is repeated,
until a spanning tree is formed
DYNAMIC PROGRAMMING
ALGORITHMS
 Dynamic programming approach for the
algorithm design solves the problems by
combining the solutions to some problems, as
we do in divide and conquer approach
 It is more powerful
 It is a stage-wise search method suitable for
optimization problems whose solutions may
be viewed as the result of a sequence of
decisions
DIJKSTRA’S ALGORITHM
 Dijkstra’s algorithm solves the single source
shortest path problems on a weighted
directed graph
 It is Greedy algorithm
 Dijkstra’s algorithm starts at the source vertex,
it grows a tree T, that spans all vertices
reachable from S
THANK YOU!!!

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture 9 data structures and algorithms
Lecture 9 data structures and algorithmsLecture 9 data structures and algorithms
Lecture 9 data structures and algorithms
Aakash deep Singhal
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
Kumar
 

Was ist angesagt? (20)

Cinterviews Binarysearch Tree
Cinterviews Binarysearch TreeCinterviews Binarysearch Tree
Cinterviews Binarysearch Tree
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Network Topology
Network TopologyNetwork Topology
Network Topology
 
Graph theory[1]
Graph theory[1]Graph theory[1]
Graph theory[1]
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Review session2
Review session2Review session2
Review session2
 
Lecture 9 data structures and algorithms
Lecture 9 data structures and algorithmsLecture 9 data structures and algorithms
Lecture 9 data structures and algorithms
 
Lec18
Lec18Lec18
Lec18
 
Binary tree
Binary treeBinary tree
Binary tree
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Splay Trees and Self Organizing Data Structures
Splay Trees and Self Organizing Data StructuresSplay Trees and Self Organizing Data Structures
Splay Trees and Self Organizing Data Structures
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix Array
 
Lecture 01 Intro to DSA
Lecture 01 Intro to DSALecture 01 Intro to DSA
Lecture 01 Intro to DSA
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
Data Structure
Data StructureData Structure
Data Structure
 
Binary tree traversal ppt
Binary tree traversal pptBinary tree traversal ppt
Binary tree traversal ppt
 
Data structure
Data structureData structure
Data structure
 
Data Structure: TREES
Data Structure: TREESData Structure: TREES
Data Structure: TREES
 
Data structure & algorithms introduction
Data structure & algorithms introductionData structure & algorithms introduction
Data structure & algorithms introduction
 

Andere mochten auch

Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 
Cmp104 lec 4 types of computer
Cmp104 lec 4 types of computerCmp104 lec 4 types of computer
Cmp104 lec 4 types of computer
kapil078
 
3 session 3a risk_pooling
3 session 3a risk_pooling3 session 3a risk_pooling
3 session 3a risk_pooling
kimsach
 

Andere mochten auch (20)

Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Insurance
InsuranceInsurance
Insurance
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Database management system
Database management systemDatabase management system
Database management system
 
Derivatives
DerivativesDerivatives
Derivatives
 
Báo cáo LVTN ThS 2011
Báo cáo LVTN ThS 2011Báo cáo LVTN ThS 2011
Báo cáo LVTN ThS 2011
 
2015.11.12 15 arc binh nguyen
2015.11.12 15 arc  binh nguyen2015.11.12 15 arc  binh nguyen
2015.11.12 15 arc binh nguyen
 
Corporate analysis and strategies
Corporate analysis and strategiesCorporate analysis and strategies
Corporate analysis and strategies
 
International HRM & Labor relations
International HRM & Labor relationsInternational HRM & Labor relations
International HRM & Labor relations
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
 
Cmp104 lec 4 types of computer
Cmp104 lec 4 types of computerCmp104 lec 4 types of computer
Cmp104 lec 4 types of computer
 
Introduction to data_structure
Introduction to data_structureIntroduction to data_structure
Introduction to data_structure
 
Data structures project
Data structures projectData structures project
Data structures project
 
3 session 3a risk_pooling
3 session 3a risk_pooling3 session 3a risk_pooling
3 session 3a risk_pooling
 
Queues
QueuesQueues
Queues
 
Understanding the concept of risk pooling
Understanding the concept of risk poolingUnderstanding the concept of risk pooling
Understanding the concept of risk pooling
 
International Hrm
International HrmInternational Hrm
International Hrm
 
Risk pooling
Risk poolingRisk pooling
Risk pooling
 

Ähnlich wie Tree

1. Briefly state the Master Theorem.What type of problem is it usefu.pdf
1. Briefly state the Master Theorem.What type of problem is it usefu.pdf1. Briefly state the Master Theorem.What type of problem is it usefu.pdf
1. Briefly state the Master Theorem.What type of problem is it usefu.pdf
sales98
 
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
 
Svm Presentation
Svm PresentationSvm Presentation
Svm Presentation
shahparin
 

Ähnlich wie Tree (20)

ntroduction to Algorithm 2.pptx
ntroduction to Algorithm 2.pptxntroduction to Algorithm 2.pptx
ntroduction to Algorithm 2.pptx
 
tree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptxtree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptx
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
Ch12 Tree
Ch12 TreeCh12 Tree
Ch12 Tree
 
Graph Algorithms
Graph AlgorithmsGraph Algorithms
Graph Algorithms
 
Binary trees1
Binary trees1Binary trees1
Binary trees1
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 
Tree chapter
Tree chapterTree chapter
Tree chapter
 
Q
QQ
Q
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
data structures module III & IV.pptx
data structures module III & IV.pptxdata structures module III & IV.pptx
data structures module III & IV.pptx
 
1. Briefly state the Master Theorem.What type of problem is it usefu.pdf
1. Briefly state the Master Theorem.What type of problem is it usefu.pdf1. Briefly state the Master Theorem.What type of problem is it usefu.pdf
1. Briefly state the Master Theorem.What type of problem is it usefu.pdf
 
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
 
Svm Presentation
Svm PresentationSvm Presentation
Svm Presentation
 
Balance tree. Short overview
Balance tree. Short overviewBalance tree. Short overview
Balance tree. Short overview
 
B.TECH Math project
B.TECH Math projectB.TECH Math project
B.TECH Math project
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
 
Trees
TreesTrees
Trees
 
Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
 

Mehr von Simran Kaur

Mehr von Simran Kaur (20)

Corporate social relationship as responsibility
Corporate social relationship as responsibilityCorporate social relationship as responsibility
Corporate social relationship as responsibility
 
Teaching aptitude
Teaching aptitudeTeaching aptitude
Teaching aptitude
 
Trade union
Trade unionTrade union
Trade union
 
Preposition
PrepositionPreposition
Preposition
 
Tense
TenseTense
Tense
 
Verb
VerbVerb
Verb
 
Let Get Make
Let Get MakeLet Get Make
Let Get Make
 
Modals
ModalsModals
Modals
 
Direct & indirect speech
Direct & indirect speechDirect & indirect speech
Direct & indirect speech
 
Active & Passive Voice
Active & Passive VoiceActive & Passive Voice
Active & Passive Voice
 
Software development life cycle (SDLC)
Software development life cycle (SDLC)Software development life cycle (SDLC)
Software development life cycle (SDLC)
 
Business cycle
Business cycleBusiness cycle
Business cycle
 
Communication
CommunicationCommunication
Communication
 
Job analysis
Job analysisJob analysis
Job analysis
 
OSI Model
OSI ModelOSI Model
OSI Model
 
Pricing Strategy
Pricing StrategyPricing Strategy
Pricing Strategy
 
Marketing research
Marketing researchMarketing research
Marketing research
 
Theories of entrepreneurship
Theories of entrepreneurshipTheories of entrepreneurship
Theories of entrepreneurship
 
Software testing
Software testingSoftware testing
Software testing
 
Computer network
Computer networkComputer network
Computer network
 

Kürzlich hochgeladen

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 

Kürzlich hochgeladen (20)

Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 

Tree

  • 2. TREE  A tree is the data structure that are based on hierarchical tree structure with set of nodes  It is an acyclic connected graph with one or more children nodes and at most one root node
  • 3. TREE TERMINOLOGY  NODE: Each data item in a tree  ROOT: First or top data item in hierarchical arrangement  DEGREE OF A NODE: Number of subtrees of a given node  DEGREE OF A TREE: Maximum degree of a node in a tree  DEPTH OR HEIGHT: Maximum level number of a node + 1(i.e., level number of farthest leaf node of a tree + 1)
  • 4. TREE TERMINOLOGY  NON-TERMINAL NODE: Any node except root node whose degree is not zero  TERMINAL NODE OR LEAF NODES: Nodes having zero  FOREST: Set of disjoint trees  PATH: Sequence of consecutive edges from the source node to the destination node
  • 5. BINARY TREE  In this kind of tree, the maximum degree of any node is at most 2  A binary tree T is defined as a finite set of elements such that T is empty (called NULL tree or empty tree) and T contains a distinguished Node R called the root of T and the remaining nodes of T form an ordered pair of disjoint binary trees 𝑇1, and 𝑇2
  • 6. FULL BINARY TREE  A binary tree in which all leaves are t the same level or at the same depth and in which every parent has exactly 0 or 2 children
  • 7. COMPLETE BINARY TREE A binary tree is one which have the following properties: i) Which can have 0, 1 or 2 nodes as a child node ii) In which first, we need to fill left node, then right node in a level iii) In which, we can start putting data item in next level only when the previous level is completely filled
  • 8. PREORDER TREE TRAVERSAL  Process the root R  Traverse the left subtree of R in preorder  Traverse the right subtree of R in preorder
  • 9. INORDER TREE TRAVERSAL  Traverse the left subtree of R in inorder  Process the root R  Traverse the right subtree of R in inorder
  • 10. POSTORDER TREE TRAVERSAL  Traverse the left subtree of R in postorder  Traverse the right subtree of R in postorder  Process the root R
  • 11. BREADTH FIRST TRAVERSAL (BFT)  The breadth first traversal of a tree visits the nodes in the order of depth in the tree  BFT first visits all the nodes at depth zero (i.e., root), then all the nodes at depth one and so on  At each depth, the nodes are visited from left to right
  • 12. DEPTH FIRST TRAVERSAL (DFT)  Depth first traversal is an algorithm for traversing or searching a tree, tree structure or graph  One starts at the root and explores as far as possible along each branch before backtracking
  • 13. BINARY SEARCH TREE A binary search tree, also called as an ordered or sorted binary tree, has following properties: i) The left subtree of a node contains only nodes with keys less than the node’s key ii) The right subtree of a node contains only nodes with keys greater than the node’s key iii) Both the left subtrees and right subtrees must also be binary search trees
  • 14. AVERAGE CASE PERFORMANCE OF BST OPERATIONS  Internal Path Length (IPL) of a binary tree is the sum of the depths of its nodes.  Average internal path length T(n) of binary trees with n nodes is O(n log n)  The average complexity to find or insert operations is T(n) = O(log n)
  • 15. AVL TREES An AVL (Adelson-Velskii and Land) is a binary tree with the following additional balance properties: i) For any node in the tree, the height of the left and right subtrees can differ by atmost ii) The height of an empty subtree is -1
  • 16. AVL TREES  An AVL is a binary search tree which has the following properties: i) The subtrees of every node differ in height by atmost one ii) Every subtree is an AVL tree  Balance factor of a node = Height of left subtree – Height of right subtree
  • 17. GREEDY ALGORITHMS  Greedy algorithms are simple and straight- forward  They are short sighted in their approach in the sense they take decisions on the basis of information at hand without worrying about the effect of these decisions in the future  They are used to solve optimization problems
  • 18. FEASIBILITY  A feasible set is promising, if it can be extended to produce not merely as solution, but an optimal solution to the problem
  • 19. SPANNING TREE  A spanning tree of a graph is any tree that includes every vertex in the graph  A spanning tree of a graph G is a subgraph of G that is a tree and contains all vertices of G  The number of spanning trees in the complete graph 𝐾 𝑛 is 𝑛 𝑛−2
  • 20. MINIMUM SPANNING TREE  A Minimum Spanning Tree (MST) of a weighted graph G is a spanning tree of G whose edges sum is minimum weight  There are two algorithms to find the minimum spanning tree of an undirected weighted graph
  • 21. KRUSKAL’S ALGORITHM  Kruskal’s algorithm is a Greedy algorithm  In this algorithm, starts with each vertex being its component. Repeatedly merges two components into one by choosing the light edge that connects them, that’s why, this algorithm is edge based algorithm
  • 22. KRUSKAL’S ALGORITHM Let G = (V,E) is a connected, undirected, weighted graph  Scans the set of edges in increasing order by weight. The edge is selected such that: i) acyclicity should be maintained, ii) it should be minimum weight, iii) when tree T contains n-1 edges, also must terminate  Uses a disjoint set of data structure to determine whether an edge connects vertices in different components
  • 23. ANALYSIS OF KRUSKAL’S ALGORITHM The total time taken by this algorithm to find the minimum spanning tree is O(E 𝑙𝑜𝑔2 E) (if edges are already sorted) But the time complexity, if edges are not sorted is O(E 𝑙𝑜𝑔2 V)
  • 24. PRIM’S ALGORITHM  Prim’s algorithm is based on a generic minimum spanning tree algorithm  The idea of Prim’s algorithm is to find the shortest path in a given graph  The Prim’s algorithm has the property that the edges in the set A always form a single connected tree
  • 25. PRIM’S ALGORITHM We begin with some vertex V in a given graph G = (V,E), defining the initial set of vertices A. Then, in each iteration, we choose a minimum weight edge (u,v), connecting a vertex v in the set A to the vertex u outside of set A. Then, vertex u is brought into A. This tree is repeated, until a spanning tree is formed
  • 26. DYNAMIC PROGRAMMING ALGORITHMS  Dynamic programming approach for the algorithm design solves the problems by combining the solutions to some problems, as we do in divide and conquer approach  It is more powerful  It is a stage-wise search method suitable for optimization problems whose solutions may be viewed as the result of a sequence of decisions
  • 27. DIJKSTRA’S ALGORITHM  Dijkstra’s algorithm solves the single source shortest path problems on a weighted directed graph  It is Greedy algorithm  Dijkstra’s algorithm starts at the source vertex, it grows a tree T, that spans all vertices reachable from S