SlideShare a Scribd company logo
2
Most read
3
Most read
8
Most read
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

More Related Content

PPTX
Hashing
PPT
Abstract data types
PPTX
linked list in data structure
PPTX
Binary Tree in Data Structure
PDF
backtracking algorithms of ada
PPTX
Doubly & Circular Linked Lists
PDF
Red black tree
PPTX
Pumping lemma Theory Of Automata
Hashing
Abstract data types
linked list in data structure
Binary Tree in Data Structure
backtracking algorithms of ada
Doubly & Circular Linked Lists
Red black tree
Pumping lemma Theory Of Automata

What's hot (20)

PPTX
Asymptotic Notation
PPTX
Sparse matrix and its representation data structure
PDF
A* Search Algorithm
PPT
Data Structures with C Linked List
PPTX
Lecture 16 memory bounded search
PPT
Control Structures In Php 2
PPTX
Data structures and algorithms
PDF
Quick Sort , Merge Sort , Heap Sort
PPTX
Insertion sort
PPTX
Searching
PPTX
Stacks and Queue - Data Structures
PPTX
Data Structures - Lecture 7 [Linked List]
PPT
Divide and conquer
DOC
Branch and bound
PDF
Bottom up parser
PPT
BINARY TREE REPRESENTATION.ppt
PPT
UNIT-1-PPTS-DAA.ppt
PPT
Graph traversal-BFS & DFS
PDF
AES-Advanced Encryption Standard
Asymptotic Notation
Sparse matrix and its representation data structure
A* Search Algorithm
Data Structures with C Linked List
Lecture 16 memory bounded search
Control Structures In Php 2
Data structures and algorithms
Quick Sort , Merge Sort , Heap Sort
Insertion sort
Searching
Stacks and Queue - Data Structures
Data Structures - Lecture 7 [Linked List]
Divide and conquer
Branch and bound
Bottom up parser
BINARY TREE REPRESENTATION.ppt
UNIT-1-PPTS-DAA.ppt
Graph traversal-BFS & DFS
AES-Advanced Encryption Standard
Ad

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

PPT
Lecture 7-BinarySearchTrees.ppt
PPTX
Lec 10_Binary Search Tree in data structure and algorithm.pptx
PPTX
9e28d06f-bae9-487e-8360-0e2c0a8c2972.pptx
PPTX
presentation 1 binary search tree in data structures.pptx
PDF
Binary search tree operations
PPTX
Binary_Search_Tree_Presentation.pptxjjwjejjejje
PPTX
Binary search tree definition operation.pptx
PPTX
BINARY TREE data structure and algorithm-1.pptx
PPT
Binary searchtrees
PPTX
Binary Search Tree
PPTX
Data- Structures-Binary-Search-Trees.pptx
PPTX
Binary tree
PDF
Trees second part in data structures with examples
PPTX
BST binary search tree with tree traversals.pptx
PDF
Binary search tree with pre-order inorder and postorder
PPTX
PPTX
Binary Search Tree
PPTX
DAA PPT.pptx
PPTX
UNIT 2 TREES & GRAPH COMPLETE NOTES OF DATA STRUCTURE
Lecture 7-BinarySearchTrees.ppt
Lec 10_Binary Search Tree in data structure and algorithm.pptx
9e28d06f-bae9-487e-8360-0e2c0a8c2972.pptx
presentation 1 binary search tree in data structures.pptx
Binary search tree operations
Binary_Search_Tree_Presentation.pptxjjwjejjejje
Binary search tree definition operation.pptx
BINARY TREE data structure and algorithm-1.pptx
Binary searchtrees
Binary Search Tree
Data- Structures-Binary-Search-Trees.pptx
Binary tree
Trees second part in data structures with examples
BST binary search tree with tree traversals.pptx
Binary search tree with pre-order inorder and postorder
Binary Search Tree
DAA PPT.pptx
UNIT 2 TREES & GRAPH COMPLETE NOTES OF DATA STRUCTURE
Ad

More from JavedKhan524377 (8)

PPTX
Deep learning intro and examples and types
PPTX
Linear Search for design and analysis of algorithm
PPTX
Greedy algorithm for design and analysis
PDF
Software Engineering Book for beginnerss
PPTX
Software tetsing paper related to industry
PPTX
Week 1 Lecture 1 LAB Weka lecture for machine learning
PPTX
lecture_for programming and computing basics
PPT
chapter_3_8 of software requirements engineering
Deep learning intro and examples and types
Linear Search for design and analysis of algorithm
Greedy algorithm for design and analysis
Software Engineering Book for beginnerss
Software tetsing paper related to industry
Week 1 Lecture 1 LAB Weka lecture for machine learning
lecture_for programming and computing basics
chapter_3_8 of software requirements engineering

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Complications of Minimal Access Surgery at WLH
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Pre independence Education in Inndia.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
VCE English Exam - Section C Student Revision Booklet
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Sports Quiz easy sports quiz sports quiz
Complications of Minimal Access Surgery at WLH
O5-L3 Freight Transport Ops (International) V1.pdf
Renaissance Architecture: A Journey from Faith to Humanism
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Supply Chain Operations Speaking Notes -ICLT Program
O7-L3 Supply Chain Operations - ICLT Program
Pre independence Education in Inndia.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Anesthesia in Laparoscopic Surgery in India
2.FourierTransform-ShortQuestionswithAnswers.pdf

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