SlideShare a Scribd company logo
Binary Search Tree
What is a Binary Search Tree?
• The binary search tree is an algorithm used for analyzing the node, its
left and right branches, which are modeled in a tree structure and
returning the value.
• The BST is devised on the architecture of a basic binary search
algorithm; hence it enables faster lookups, insertions, and removals of
nodes.
• This makes the program really fast and accurate.
• A BST is made of multiple nodes and consists of the following attributes:
• Nodes of the tree are represented in a parent-child relationship
• Each parent node can have zero child nodes or a maximum of two subnodes.
• Every sub-tree, also known as a binary search tree, has sub-branches on the
right and left of themselves.
• The keys of the nodes present on the left subtree are smaller than the keys of
their parent node
Binary Search Tree for design and analysis
• BST is commonly utilized to implement complex searches, robust
game logics, auto-complete activities, and graphics.
• The algorithm efficiently supports operations like search, insert, and
delete.
• BST primarily offers the following three types of operations for your
usage:
• Search: searches the element from the binary tree
• Insert: adds an element to the binary tree
• Delete: delete the element from a binary tree
Search Operation
• Always start analyzing tree at the root node.
• Then move further to either the right or left subtree of the root node
depending on the element to be located is either less or greater than the
root.
Binary Search Tree for design and analysis
• The element to be searched is 10
• Compare the element with the root node 12, 10 < 12, hence you move
to the left subtree. No need to analyze the right-subtree
• Now compare 10 with node 7, 10 > 7, so move to the right-subtree
• Then compare 10 with the next node, which is 9, 10 > 9, look in the
right subtree child
• 10 matches with the value in the node, 10 = 10, return the value to the
user.
Pseudo Code for Searching in BST
• search(element, root)
• if !root
• return -1
• if root.value == element
• return 1
• if root.value < element
• search(element, root.right)
• else
• search(element, root.left)
Insert Operation
• This is a very straight forward operation.
• First, the root node is inserted, then the next value is compared with
the root node. If the value is greater than root, it is added to the right
subtree, and if it is lesser than the root, it is added to the left subtree.
• There is a list of 6 elements that need to be inserted in a BST in order
from left to right ( 12, 7, 9, 19, 5, 10)
• Insert 12 as the root node and compare next values 7 and 9 for
inserting accordingly into the right and left subtree
• Compare the remaining values 19, 5, and 10 with the root node 12 and
place them accordingly. 19 > 12 place it as the right child of 12, 5 < 12
& 5 < 7, hence place it as left child of 7.
• Now compare 10, 10 is < 12 & 10 is > 7 & 10 is > 9, place 10 as right
subtree of 9.
Binary Search Tree for design and analysis
• You should practice in lab (tomorrow) about different ways of
Delete operation of BST
Ad

More Related Content

What's hot (20)

b+ tree
b+ treeb+ tree
b+ tree
bitistu
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
INAM352782
 
Heap Sort in Design and Analysis of algorithms
Heap Sort in Design and Analysis of algorithmsHeap Sort in Design and Analysis of algorithms
Heap Sort in Design and Analysis of algorithms
samairaakram
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
koolkampus
 
Linked stacks and queues
Linked stacks and queuesLinked stacks and queues
Linked stacks and queues
Ramzi Alqrainy
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
Huba Akhtar
 
Threaded binary tree
Threaded binary treeThreaded binary tree
Threaded binary tree
ArunaP47
 
Active database system
Active database systemActive database system
Active database system
Adeolu Olaniyan
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
Reggie Niccolo Santos
 
Measures of query cost
Measures of query costMeasures of query cost
Measures of query cost
Hitesh Mohapatra
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
Abhishek L.R
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
Zia Ush Shamszaman
 
Data storage and indexing
Data storage and indexingData storage and indexing
Data storage and indexing
pradeepa velmurugan
 
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
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
Kamran Zafar
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Meghaj Mallick
 
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
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
Dhrumil Panchal
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
INAM352782
 
Heap Sort in Design and Analysis of algorithms
Heap Sort in Design and Analysis of algorithmsHeap Sort in Design and Analysis of algorithms
Heap Sort in Design and Analysis of algorithms
samairaakram
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
koolkampus
 
Linked stacks and queues
Linked stacks and queuesLinked stacks and queues
Linked stacks and queues
Ramzi Alqrainy
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
Huba Akhtar
 
Threaded binary tree
Threaded binary treeThreaded binary tree
Threaded binary tree
ArunaP47
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
Abhishek L.R
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
Zia Ush Shamszaman
 
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
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
Kamran Zafar
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Meghaj Mallick
 
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
 

Similar to Binary Search Tree for design and analysis (20)

lecture on introduction to Binary Search Tree
lecture on introduction to Binary Search Treelecture on introduction to Binary Search Tree
lecture on introduction to Binary Search Tree
JayfTayuanMangansaka
 
presentation 1 binary search tree in data structures.pptx
presentation 1  binary search tree in data structures.pptxpresentation 1  binary search tree in data structures.pptx
presentation 1 binary search tree in data structures.pptx
TayybaGhaffar1
 
Group 5-DSA.pptx........................
Group 5-DSA.pptx........................Group 5-DSA.pptx........................
Group 5-DSA.pptx........................
salmannawaz6566504
 
learn tree, linked list, queue, stack, and other algo
learn tree, linked list, queue, stack, and other algolearn tree, linked list, queue, stack, and other algo
learn tree, linked list, queue, stack, and other algo
unknowwqer
 
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
4. Apply data structures such as arrays, linked lists, and trees as an abstra...4. Apply data structures such as arrays, linked lists, and trees as an abstra...
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
deivasigamani9
 
Lec 10_Binary Search Tree in data structure and algorithm.pptx
Lec 10_Binary Search Tree in data structure and algorithm.pptxLec 10_Binary Search Tree in data structure and algorithm.pptx
Lec 10_Binary Search Tree in data structure and algorithm.pptx
hinamazhar6
 
binary search tree
binary search treebinary search tree
binary search tree
Halabja university - Kurdistan -Iraq
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
Binary search tree.pptx
Binary search tree.pptxBinary search tree.pptx
Binary search tree.pptx
Benazir Bhutto Shaheed University Lyari Karachi
 
Database Engine
Database EngineDatabase Engine
Database Engine
prashanthbabu07
 
M.E - Computer Science and Engineering-Data structure-bst-and-threaded
M.E - Computer Science and Engineering-Data structure-bst-and-threadedM.E - Computer Science and Engineering-Data structure-bst-and-threaded
M.E - Computer Science and Engineering-Data structure-bst-and-threaded
poonkodiraja2806
 
Trees second part in data structures with examples
Trees second part in data structures with examplesTrees second part in data structures with examples
Trees second part in data structures with examples
rupanaveen24
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap tree
zia eagle
 
Binary trees
Binary treesBinary trees
Binary trees
Amit Vats
 
Binary tree
Binary treeBinary tree
Binary tree
Afaq Mansoor Khan
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
Sana Yameen
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
maamir farooq
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
Rj Juhith
 
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTINGSEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
mohanrajm63
 
Binary tree
Binary treeBinary tree
Binary tree
Maria Saleem
 
lecture on introduction to Binary Search Tree
lecture on introduction to Binary Search Treelecture on introduction to Binary Search Tree
lecture on introduction to Binary Search Tree
JayfTayuanMangansaka
 
presentation 1 binary search tree in data structures.pptx
presentation 1  binary search tree in data structures.pptxpresentation 1  binary search tree in data structures.pptx
presentation 1 binary search tree in data structures.pptx
TayybaGhaffar1
 
Group 5-DSA.pptx........................
Group 5-DSA.pptx........................Group 5-DSA.pptx........................
Group 5-DSA.pptx........................
salmannawaz6566504
 
learn tree, linked list, queue, stack, and other algo
learn tree, linked list, queue, stack, and other algolearn tree, linked list, queue, stack, and other algo
learn tree, linked list, queue, stack, and other algo
unknowwqer
 
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
4. Apply data structures such as arrays, linked lists, and trees as an abstra...4. Apply data structures such as arrays, linked lists, and trees as an abstra...
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
deivasigamani9
 
Lec 10_Binary Search Tree in data structure and algorithm.pptx
Lec 10_Binary Search Tree in data structure and algorithm.pptxLec 10_Binary Search Tree in data structure and algorithm.pptx
Lec 10_Binary Search Tree in data structure and algorithm.pptx
hinamazhar6
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
M.E - Computer Science and Engineering-Data structure-bst-and-threaded
M.E - Computer Science and Engineering-Data structure-bst-and-threadedM.E - Computer Science and Engineering-Data structure-bst-and-threaded
M.E - Computer Science and Engineering-Data structure-bst-and-threaded
poonkodiraja2806
 
Trees second part in data structures with examples
Trees second part in data structures with examplesTrees second part in data structures with examples
Trees second part in data structures with examples
rupanaveen24
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap tree
zia eagle
 
Binary trees
Binary treesBinary trees
Binary trees
Amit Vats
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
Sana Yameen
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
Rj Juhith
 
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTINGSEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
mohanrajm63
 
Ad

More from JavedKhan524377 (8)

Deep learning intro and examples and types
Deep learning intro and examples and typesDeep learning intro and examples and types
Deep learning intro and examples and types
JavedKhan524377
 
Linear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithmLinear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithm
JavedKhan524377
 
Greedy algorithm for design and analysis
Greedy algorithm for design and analysisGreedy algorithm for design and analysis
Greedy algorithm for design and analysis
JavedKhan524377
 
Software Engineering Book for beginnerss
Software Engineering Book for beginnerssSoftware Engineering Book for beginnerss
Software Engineering Book for beginnerss
JavedKhan524377
 
Software tetsing paper related to industry
Software tetsing paper related to industrySoftware tetsing paper related to industry
Software tetsing paper related to industry
JavedKhan524377
 
Week 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learningWeek 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learning
JavedKhan524377
 
lecture_for programming and computing basics
lecture_for programming and computing basicslecture_for programming and computing basics
lecture_for programming and computing basics
JavedKhan524377
 
chapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineeringchapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineering
JavedKhan524377
 
Deep learning intro and examples and types
Deep learning intro and examples and typesDeep learning intro and examples and types
Deep learning intro and examples and types
JavedKhan524377
 
Linear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithmLinear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithm
JavedKhan524377
 
Greedy algorithm for design and analysis
Greedy algorithm for design and analysisGreedy algorithm for design and analysis
Greedy algorithm for design and analysis
JavedKhan524377
 
Software Engineering Book for beginnerss
Software Engineering Book for beginnerssSoftware Engineering Book for beginnerss
Software Engineering Book for beginnerss
JavedKhan524377
 
Software tetsing paper related to industry
Software tetsing paper related to industrySoftware tetsing paper related to industry
Software tetsing paper related to industry
JavedKhan524377
 
Week 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learningWeek 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learning
JavedKhan524377
 
lecture_for programming and computing basics
lecture_for programming and computing basicslecture_for programming and computing basics
lecture_for programming and computing basics
JavedKhan524377
 
chapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineeringchapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineering
JavedKhan524377
 
Ad

Recently uploaded (20)

How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 

Binary Search Tree for design and analysis

  • 2. What is a Binary Search Tree? • The binary search tree is an algorithm used for analyzing the node, its left and right branches, which are modeled in a tree structure and returning the value. • The BST is devised on the architecture of a basic binary search algorithm; hence it enables faster lookups, insertions, and removals of nodes. • This makes the program really fast and accurate.
  • 3. • A BST is made of multiple nodes and consists of the following attributes: • Nodes of the tree are represented in a parent-child relationship • Each parent node can have zero child nodes or a maximum of two subnodes. • Every sub-tree, also known as a binary search tree, has sub-branches on the right and left of themselves. • The keys of the nodes present on the left subtree are smaller than the keys of their parent node
  • 5. • BST is commonly utilized to implement complex searches, robust game logics, auto-complete activities, and graphics. • The algorithm efficiently supports operations like search, insert, and delete.
  • 6. • BST primarily offers the following three types of operations for your usage: • Search: searches the element from the binary tree • Insert: adds an element to the binary tree • Delete: delete the element from a binary tree
  • 7. Search Operation • Always start analyzing tree at the root node. • Then move further to either the right or left subtree of the root node depending on the element to be located is either less or greater than the root.
  • 9. • The element to be searched is 10 • Compare the element with the root node 12, 10 < 12, hence you move to the left subtree. No need to analyze the right-subtree • Now compare 10 with node 7, 10 > 7, so move to the right-subtree • Then compare 10 with the next node, which is 9, 10 > 9, look in the right subtree child • 10 matches with the value in the node, 10 = 10, return the value to the user.
  • 10. Pseudo Code for Searching in BST • search(element, root) • if !root • return -1 • if root.value == element • return 1 • if root.value < element • search(element, root.right) • else • search(element, root.left)
  • 11. Insert Operation • This is a very straight forward operation. • First, the root node is inserted, then the next value is compared with the root node. If the value is greater than root, it is added to the right subtree, and if it is lesser than the root, it is added to the left subtree.
  • 12. • There is a list of 6 elements that need to be inserted in a BST in order from left to right ( 12, 7, 9, 19, 5, 10) • Insert 12 as the root node and compare next values 7 and 9 for inserting accordingly into the right and left subtree • Compare the remaining values 19, 5, and 10 with the root node 12 and place them accordingly. 19 > 12 place it as the right child of 12, 5 < 12 & 5 < 7, hence place it as left child of 7. • Now compare 10, 10 is < 12 & 10 is > 7 & 10 is > 9, place 10 as right subtree of 9.
  • 14. • You should practice in lab (tomorrow) about different ways of Delete operation of BST
  翻译: