SlideShare a Scribd company logo
Trees
Introduction
 Is a non linear data structure.
 Is a hierarchical data structure.
 Is a finite set of nodes.
 Contains a special node called root node.
 All nodes are connecting through an edge.
Terminologies…
 Degree of a Node
Means number of child nodes a node have.
 Leaf
Nodes that have no child nodes.
 Terminal Nodes
Leaf nodes are also called terminal nodes.
 Degree of a tree
Maximum degree of tree is called degree of
tree.
 Ancestors
All the parent nodes of a node till rood node
path called its ancestors.
 Descendants
All the child nodes of a node till leaf node
path called its ancestors.
 Generation
All nodes with same level called a generation.
 Height/Depth
Number of levels / Generations .
 Edge
Connecting lines that are used to connect
nodes.
 Path
sequence of consective edges from 1 node
to other node.
 Branch
if a path ends at leaf nodes called branch.
How to construct tree data
structure.
 We can construct it using Linked List.
Binary Tree
 A tree having a property that all nodes should
have minimum 0 nodes or maximum 2 nodes.
>=0 nodes <=2.
 If 0 nodes called empty tree/null tree.
Types
1: Full BT
- a tree in which each level is filled
completely.
- non leaf nodes should have left as well as
right child's.
- all the leaf nodes should be at same level.
2: Complete Binary tree
each node must have 2 child's (left and right
as well) except leaf nodes.
3: Incomplete binary tree
tree may violate the property of complete
binary tree.
Almost complete binary tree
 A tree having all leaf nodes at last or second
last level called almost complete binary tree.
Binary Search Tree
 A binary tree in which minimum value is
placed at the left side of node and maximum
value at right side of node.
Operations
 Insertion
 Searching
 Deletion
Insertion in BST
 Place first at root node.
 Now compare each node value to decide
whether your coming value will be placed at
right or left side of node.
 Takes O(n) in worst case
 Takes Big-Theta (log n) in average case.
Searching
 Compare the target value by moving from one
node to other starting from root node.
 Move left if targeted value is smaller than
node value else move right.
 Takes O(n) in worst case
 Takes Big-Theta (log n) in average case.
Deletion
 Cases
 If the node is leaf
 If node in non-leaf and have 1 child node.
 If node is non-leaf and have 2 child nodes.
If the node is leaf
 Delete that node and make its father node
pointing to Null.
 Left pointer in case of left leaf
 Right pointer in case of right leaf
If node is non-leaf and having 1
child node.
 If deleted node is right child of its parent
 Delete the node.
 If have right child or Left Child
 Make it the Right child of deleted node’s
parent.
 If deleted node is left child of its parent
 Delete the node.
 If have right child or Left Child
 Make it the left child of deleted node’s
parent.
Trees

More Related Content

What's hot

Circular linked list
Circular linked listCircular linked list
Circular linked list
chauhankapil
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
SIVASHANKARIRAJAN
 
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
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
shameen khan
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
maamir farooq
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
Adam Mukharil Bachtiar
 
Binary tree
Binary  treeBinary  tree
Binary tree
Vanitha Chandru
 
AVL Tree Data Structure
AVL Tree Data StructureAVL Tree Data Structure
AVL Tree Data Structure
Afaq Mansoor Khan
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 
Tree
TreeTree
Tree
bhumish
 
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
Srajan Shukla
 
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 

What's hot (20)

Circular linked list
Circular linked listCircular linked list
Circular linked list
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
 
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
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
AVL Tree Data Structure
AVL Tree Data StructureAVL Tree Data Structure
AVL Tree Data Structure
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Tree
TreeTree
Tree
 
Expression trees
Expression treesExpression trees
Expression trees
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 

Similar to Trees

NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
Rajitha Reddy Alugati
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
Abirami A
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
SIVAKUMARM603675
 
Final tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationFinal tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentation
nakulvarshney371
 
Trees
TreesTrees
Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
Guru Nanak Institute Of Tech
 
Tree data structure
Tree data structureTree data structure
Tree data structure
Lovely Professional University
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
BHARATH KUMAR
 
Trees in data structures
Trees in data structuresTrees in data structures
Trees in data structures
ASairamSairam1
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
worldchannel
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
smruti sarangi
 
Trees
TreesTrees
Describe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docxDescribe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docx
andyb37
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
Muhazzab Chouhadry
 
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
RupaRaj6
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Unit 5 Tree.pptx
Unit 5 Tree.pptxUnit 5 Tree.pptx
Unit 5 Tree.pptx
SurajSharma266169
 
tree traversals.pdf
tree traversals.pdftree traversals.pdf
tree traversals.pdf
MaryJacob24
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 

Similar to Trees (20)

NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
 
Final tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationFinal tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentation
 
Trees
TreesTrees
Trees
 
Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
 
Tree data structure
Tree data structureTree data structure
Tree data structure
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
 
Trees in data structures
Trees in data structuresTrees in data structures
Trees in data structures
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
 
Trees
TreesTrees
Trees
 
Describe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docxDescribe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docx
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
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
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
 
Unit 5 Tree.pptx
Unit 5 Tree.pptxUnit 5 Tree.pptx
Unit 5 Tree.pptx
 
tree traversals.pdf
tree traversals.pdftree traversals.pdf
tree traversals.pdf
 
Lecture 5 trees
Lecture 5 treesLecture 5 trees
Lecture 5 trees
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
 

More from Burhan Ahmed

Wireless mobile communication
Wireless mobile communicationWireless mobile communication
Wireless mobile communication
Burhan Ahmed
 
Virtual function
Virtual functionVirtual function
Virtual function
Burhan Ahmed
 
Uses misuses and risk of software
Uses misuses and risk of softwareUses misuses and risk of software
Uses misuses and risk of software
Burhan Ahmed
 
Types of computer
Types of computerTypes of computer
Types of computer
Burhan Ahmed
 
Topology
TopologyTopology
Topology
Burhan Ahmed
 
The distinction of prophet muhammad (s.a.w) among the teachers of moral conduct
The distinction of prophet muhammad (s.a.w) among the teachers of moral conductThe distinction of prophet muhammad (s.a.w) among the teachers of moral conduct
The distinction of prophet muhammad (s.a.w) among the teachers of moral conduct
Burhan Ahmed
 
Software house organization
Software house organizationSoftware house organization
Software house organization
Burhan Ahmed
 
Social interaction
Social interactionSocial interaction
Social interaction
Burhan Ahmed
 
Role model
Role modelRole model
Role model
Burhan Ahmed
 
Rights and duties
Rights and dutiesRights and duties
Rights and duties
Burhan Ahmed
 
Planning work activities
Planning work activitiesPlanning work activities
Planning work activities
Burhan Ahmed
 
Peripheral devices
Peripheral devicesPeripheral devices
Peripheral devices
Burhan Ahmed
 
Parallel computing and its applications
Parallel computing and its applicationsParallel computing and its applications
Parallel computing and its applications
Burhan Ahmed
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Burhan Ahmed
 
Normalization
NormalizationNormalization
Normalization
Burhan Ahmed
 
Managing strategy
Managing strategyManaging strategy
Managing strategy
Burhan Ahmed
 
Letter writing
Letter writingLetter writing
Letter writing
Burhan Ahmed
 
Job analysis and job design
Job analysis and job designJob analysis and job design
Job analysis and job design
Burhan Ahmed
 
Intellectual property
Intellectual propertyIntellectual property
Intellectual property
Burhan Ahmed
 
Inheritance
InheritanceInheritance
Inheritance
Burhan Ahmed
 

More from Burhan Ahmed (20)

Wireless mobile communication
Wireless mobile communicationWireless mobile communication
Wireless mobile communication
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Uses misuses and risk of software
Uses misuses and risk of softwareUses misuses and risk of software
Uses misuses and risk of software
 
Types of computer
Types of computerTypes of computer
Types of computer
 
Topology
TopologyTopology
Topology
 
The distinction of prophet muhammad (s.a.w) among the teachers of moral conduct
The distinction of prophet muhammad (s.a.w) among the teachers of moral conductThe distinction of prophet muhammad (s.a.w) among the teachers of moral conduct
The distinction of prophet muhammad (s.a.w) among the teachers of moral conduct
 
Software house organization
Software house organizationSoftware house organization
Software house organization
 
Social interaction
Social interactionSocial interaction
Social interaction
 
Role model
Role modelRole model
Role model
 
Rights and duties
Rights and dutiesRights and duties
Rights and duties
 
Planning work activities
Planning work activitiesPlanning work activities
Planning work activities
 
Peripheral devices
Peripheral devicesPeripheral devices
Peripheral devices
 
Parallel computing and its applications
Parallel computing and its applicationsParallel computing and its applications
Parallel computing and its applications
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Normalization
NormalizationNormalization
Normalization
 
Managing strategy
Managing strategyManaging strategy
Managing strategy
 
Letter writing
Letter writingLetter writing
Letter writing
 
Job analysis and job design
Job analysis and job designJob analysis and job design
Job analysis and job design
 
Intellectual property
Intellectual propertyIntellectual property
Intellectual property
 
Inheritance
InheritanceInheritance
Inheritance
 

Recently uploaded

Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 

Trees

  • 2. Introduction  Is a non linear data structure.  Is a hierarchical data structure.  Is a finite set of nodes.  Contains a special node called root node.  All nodes are connecting through an edge.
  • 3.
  • 4. Terminologies…  Degree of a Node Means number of child nodes a node have.  Leaf Nodes that have no child nodes.  Terminal Nodes Leaf nodes are also called terminal nodes.
  • 5.  Degree of a tree Maximum degree of tree is called degree of tree.  Ancestors All the parent nodes of a node till rood node path called its ancestors.  Descendants All the child nodes of a node till leaf node path called its ancestors.
  • 6.  Generation All nodes with same level called a generation.  Height/Depth Number of levels / Generations .  Edge Connecting lines that are used to connect nodes.
  • 7.  Path sequence of consective edges from 1 node to other node.  Branch if a path ends at leaf nodes called branch.
  • 8. How to construct tree data structure.  We can construct it using Linked List.
  • 9. Binary Tree  A tree having a property that all nodes should have minimum 0 nodes or maximum 2 nodes. >=0 nodes <=2.  If 0 nodes called empty tree/null tree.
  • 10.
  • 11. Types 1: Full BT - a tree in which each level is filled completely. - non leaf nodes should have left as well as right child's. - all the leaf nodes should be at same level.
  • 12.
  • 13. 2: Complete Binary tree each node must have 2 child's (left and right as well) except leaf nodes. 3: Incomplete binary tree tree may violate the property of complete binary tree.
  • 14.
  • 15. Almost complete binary tree  A tree having all leaf nodes at last or second last level called almost complete binary tree.
  • 16. Binary Search Tree  A binary tree in which minimum value is placed at the left side of node and maximum value at right side of node.
  • 18. Insertion in BST  Place first at root node.  Now compare each node value to decide whether your coming value will be placed at right or left side of node.  Takes O(n) in worst case  Takes Big-Theta (log n) in average case.
  • 19. Searching  Compare the target value by moving from one node to other starting from root node.  Move left if targeted value is smaller than node value else move right.  Takes O(n) in worst case  Takes Big-Theta (log n) in average case.
  • 20. Deletion  Cases  If the node is leaf  If node in non-leaf and have 1 child node.  If node is non-leaf and have 2 child nodes.
  • 21. If the node is leaf  Delete that node and make its father node pointing to Null.  Left pointer in case of left leaf  Right pointer in case of right leaf
  • 22. If node is non-leaf and having 1 child node.  If deleted node is right child of its parent  Delete the node.  If have right child or Left Child  Make it the Right child of deleted node’s parent.
  • 23.  If deleted node is left child of its parent  Delete the node.  If have right child or Left Child  Make it the left child of deleted node’s parent.