SlideShare a Scribd company logo
PRESENTATION
BINARY SEARCH TREE OPERATION
DEFINATION OF BINARY SEARCH TREE
Binary Search Tree is a node-based binary tree data
structure which has the following properties.
•The left subtree of a node contains only nodes with key
lesser than the node's key.
•The right subtree of a node contains only
node with keys greater than the node's key.
DIAGRAM OF TREE
BASIC OPERATION
•#1) INSERT
•#2)DELETE
•#3)SEARCH
•#4)TRAVERSAL
ADVANTAGES OF BST
•#1)Searching Is Very Efficient
We have all the nodes of BST in a specific order, hence searching for a
particular item is very efficient and faster. This is because we need not search
the entire and compare all nodes.
We just have to compare the root node to the item which we are searching and
then we decide whether we need to search in the left or right subtree.
ADVANTAGES OF BST
•#2) Efficient Working When Compared To
Array And Linked Lists
When we search an item in case of BST, we get rid of half of the left or right
subtree at every step thereby improving the performance of search operation.
This is in contrast to array or linked list in which we need to compare all the
items sequentially to search a particular.
ADVANTAGES OF BST
•#3)Insert And Delete Are Faster
Insert and delete operations also are faster when compared to other data
structures like Linked Lists and Array.
APPLICTION OF BST
• BST is used to implement multilevel indexing in database application.
• BST is also used to implement constructs like a dictionary.
• BST can be used to implement various efficient searching algorithms.
• BST is also used in applications that require a sorted list as input
like the online stories.
• BSTs are also used to evaluate expression using expression trees.
CONCLUTION
Binary search trees(BST) are a variation of the binary tree and are widely used
in the software field. They are also called ordered binary trees as each node in
BST is placed according to a specific order.
Inorder traversal of BST gives us the sorted sequence of items in ascending
order. When BSTs are used for searching, it is very efficient and is done within
no time. BSTs are also used for a variety of application like Huffman's coding,
Multilevel index in database ,etc.
OPERATIONS
SEARCH OPERATION
The Algorithm depends on the property of BST that if each left subtree has
value below root and each right subtree has value above the root.
If the value is below the root, we can say for sure that the value is not in the
right subtree; we need to only search in the left subtree and if the value above
root, we can say for sure that value is not in the left subtree; we need to only
search in the right subtree.
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
INSERT OPERATION
Inserting a value in the correct position is similar to searching because we try to
maintain the rule that the left subtree is lesser than root and the right subtree is
larger than root.
We keep going to either right subtree depending on the value and when we
reach a point left or right subtree is null, we put the new code there.
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
DELETE OPERATION
There are three cases for deleting a node from a binary
search tree.
CASE-1
In the first case, the node to be delete is the leaf node. In such a case, simply
delete the node from the tree.
CASE-2
In the second case, the node to be deleted lies has a single child node.
In such cases follow the step below
1.Replace that node with its child node.
2.Remove the child node from its original position.
Binary search tree operations
CASE-3
• In the third case, the node to be deleted has two children. In such a case
follow the steps below:
1.Get the inorder successor of that.
2.Replace the node with the inorder successor.
3.Remove the inorder successor from its original position.
VISUALIZE BY DIAGRAM
VISUALIZE BY DIAGRAM
PRESENTED BY:
•Ehsan ul khaliq (F20-BsCS-5004)
•Faisal Shehzad (F20-BsCS-5030)
•Kamran Zafar (F20-BsCS-5039)

More Related Content

PPTX
Binary Search Tree
sagar yadav
 
PPTX
Linked list
akshat360
 
PPT
1.1 binary tree
Krish_ver2
 
PPTX
STACKS IN DATASTRUCTURE
Archie Jamwal
 
PDF
Binary tree
Rajendran
 
PPT
Java Presentation
pm2214
 
PDF
Customer satisfaction of ebanking/online banking of SBI
Sajid Nasar
 
PPT
Binary search tree(bst)
Hossain Md Shakhawat
 
Binary Search Tree
sagar yadav
 
Linked list
akshat360
 
1.1 binary tree
Krish_ver2
 
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Binary tree
Rajendran
 
Java Presentation
pm2214
 
Customer satisfaction of ebanking/online banking of SBI
Sajid Nasar
 
Binary search tree(bst)
Hossain Md Shakhawat
 

What's hot (20)

PPTX
AVL Tree in Data Structure
Vrushali Dhanokar
 
PPT
Red black tree
Rajendran
 
PPT
Binary search tree in data structures
chauhankapil
 
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
PPTX
Queue in Data Structure
Janki Shah
 
PPTX
Doubly Linked List
V.V.Vanniaperumal College for Women
 
PDF
Expression trees
Salman Vadsarya
 
PPT
Operations on linked list
Sumathi Kv
 
PPTX
queue & its applications
somendra kumar
 
PPT
Circular linked list
chauhankapil
 
PPTX
AVL Tree Data Structure
Afaq Mansoor Khan
 
PPTX
Linked List
Ashim Lamichhane
 
PPT
1.5 binary search tree
Krish_ver2
 
PPT
Linked lists
SARITHA REDDY
 
PPTX
trees in data structure
shameen khan
 
PDF
Singly linked list
Amar Jukuntla
 
PPTX
stack & queue
manju rani
 
PPTX
Binary Search Tree
Abhishek L.R
 
PPTX
Graph traversals in Data Structures
Anandhasilambarasan D
 
PPT
Binary tree
Vanitha Chandru
 
AVL Tree in Data Structure
Vrushali Dhanokar
 
Red black tree
Rajendran
 
Binary search tree in data structures
chauhankapil
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Queue in Data Structure
Janki Shah
 
Expression trees
Salman Vadsarya
 
Operations on linked list
Sumathi Kv
 
queue & its applications
somendra kumar
 
Circular linked list
chauhankapil
 
AVL Tree Data Structure
Afaq Mansoor Khan
 
Linked List
Ashim Lamichhane
 
1.5 binary search tree
Krish_ver2
 
Linked lists
SARITHA REDDY
 
trees in data structure
shameen khan
 
Singly linked list
Amar Jukuntla
 
stack & queue
manju rani
 
Binary Search Tree
Abhishek L.R
 
Graph traversals in Data Structures
Anandhasilambarasan D
 
Binary tree
Vanitha Chandru
 
Ad

Similar to Binary search tree operations (20)

PPTX
Lec 10_Binary Search Tree in data structure and algorithm.pptx
hinamazhar6
 
PPTX
Binary Search Tree
INAM352782
 
PPTX
DAA PPT.pptx
INAM352782
 
PPTX
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
deivasigamani9
 
PPTX
lecture on introduction to Binary Search Tree
JayfTayuanMangansaka
 
PPTX
Data- Structures-Binary-Search-Trees.pptx
selvi653915
 
PPTX
presentation 1 binary search tree in data structures.pptx
TayybaGhaffar1
 
PPT
Binary trees
Amit Vats
 
PPTX
Binary search tree definition operation.pptx
jeevananandk28
 
PPTX
Binary Search Tree for design and analysis
JavedKhan524377
 
PPTX
binary search tree
Halabja university - Kurdistan -Iraq
 
PPTX
Database Engine
prashanthbabu07
 
PPTX
9e28d06f-bae9-487e-8360-0e2c0a8c2972.pptx
alagark070605
 
PPTX
Group 5-DSA.pptx........................
salmannawaz6566504
 
PDF
Trees second part in data structures with examples
rupanaveen24
 
PPT
M.E - Computer Science and Engineering-Data structure-bst-and-threaded
poonkodiraja2806
 
PPTX
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
mohanrajm63
 
PPTX
Binary tree
Afaq Mansoor Khan
 
PPTX
Binary Search Tree
MuhammadShafi89
 
PPTX
learn tree, linked list, queue, stack, and other algo
unknowwqer
 
Lec 10_Binary Search Tree in data structure and algorithm.pptx
hinamazhar6
 
Binary Search Tree
INAM352782
 
DAA PPT.pptx
INAM352782
 
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
deivasigamani9
 
lecture on introduction to Binary Search Tree
JayfTayuanMangansaka
 
Data- Structures-Binary-Search-Trees.pptx
selvi653915
 
presentation 1 binary search tree in data structures.pptx
TayybaGhaffar1
 
Binary trees
Amit Vats
 
Binary search tree definition operation.pptx
jeevananandk28
 
Binary Search Tree for design and analysis
JavedKhan524377
 
Database Engine
prashanthbabu07
 
9e28d06f-bae9-487e-8360-0e2c0a8c2972.pptx
alagark070605
 
Group 5-DSA.pptx........................
salmannawaz6566504
 
Trees second part in data structures with examples
rupanaveen24
 
M.E - Computer Science and Engineering-Data structure-bst-and-threaded
poonkodiraja2806
 
SEARCHING AND SORTING ALGORITHMS, TYPES OF SORTING
mohanrajm63
 
Binary tree
Afaq Mansoor Khan
 
Binary Search Tree
MuhammadShafi89
 
learn tree, linked list, queue, stack, and other algo
unknowwqer
 
Ad

More from Kamran Zafar (12)

PPTX
DFA Assignment solution.pptx
Kamran Zafar
 
PPTX
TOA_WEEK 14.pptx
Kamran Zafar
 
PPTX
Drones in agri. by eskill india
Kamran Zafar
 
PDF
exercise 3.3 solution /class 12th/ mathcity
Kamran Zafar
 
PPTX
Lec 1 number systems converted
Kamran Zafar
 
PDF
Lecture 5 binary_codes
Kamran Zafar
 
PPT
Lecture java continued 1
Kamran Zafar
 
PPT
Lecture java continued
Kamran Zafar
 
PPT
Lecture 1 programming fundamentals (PF)
Kamran Zafar
 
PPT
digital systems and information
Kamran Zafar
 
PDF
02 computing magazine september 2012
Kamran Zafar
 
DOCX
Learn microsoft word from tayyab riaz
Kamran Zafar
 
DFA Assignment solution.pptx
Kamran Zafar
 
TOA_WEEK 14.pptx
Kamran Zafar
 
Drones in agri. by eskill india
Kamran Zafar
 
exercise 3.3 solution /class 12th/ mathcity
Kamran Zafar
 
Lec 1 number systems converted
Kamran Zafar
 
Lecture 5 binary_codes
Kamran Zafar
 
Lecture java continued 1
Kamran Zafar
 
Lecture java continued
Kamran Zafar
 
Lecture 1 programming fundamentals (PF)
Kamran Zafar
 
digital systems and information
Kamran Zafar
 
02 computing magazine september 2012
Kamran Zafar
 
Learn microsoft word from tayyab riaz
Kamran Zafar
 

Recently uploaded (20)

PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Exploring AI Agents in Process Industries
amoreira6
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 

Binary search tree operations

  • 2. DEFINATION OF BINARY SEARCH TREE Binary Search Tree is a node-based binary tree data structure which has the following properties. •The left subtree of a node contains only nodes with key lesser than the node's key. •The right subtree of a node contains only node with keys greater than the node's key.
  • 5. ADVANTAGES OF BST •#1)Searching Is Very Efficient We have all the nodes of BST in a specific order, hence searching for a particular item is very efficient and faster. This is because we need not search the entire and compare all nodes. We just have to compare the root node to the item which we are searching and then we decide whether we need to search in the left or right subtree.
  • 6. ADVANTAGES OF BST •#2) Efficient Working When Compared To Array And Linked Lists When we search an item in case of BST, we get rid of half of the left or right subtree at every step thereby improving the performance of search operation. This is in contrast to array or linked list in which we need to compare all the items sequentially to search a particular.
  • 7. ADVANTAGES OF BST •#3)Insert And Delete Are Faster Insert and delete operations also are faster when compared to other data structures like Linked Lists and Array.
  • 8. APPLICTION OF BST • BST is used to implement multilevel indexing in database application. • BST is also used to implement constructs like a dictionary. • BST can be used to implement various efficient searching algorithms. • BST is also used in applications that require a sorted list as input like the online stories. • BSTs are also used to evaluate expression using expression trees.
  • 9. CONCLUTION Binary search trees(BST) are a variation of the binary tree and are widely used in the software field. They are also called ordered binary trees as each node in BST is placed according to a specific order. Inorder traversal of BST gives us the sorted sequence of items in ascending order. When BSTs are used for searching, it is very efficient and is done within no time. BSTs are also used for a variety of application like Huffman's coding, Multilevel index in database ,etc.
  • 11. SEARCH OPERATION The Algorithm depends on the property of BST that if each left subtree has value below root and each right subtree has value above the root. If the value is below the root, we can say for sure that the value is not in the right subtree; we need to only search in the left subtree and if the value above root, we can say for sure that value is not in the left subtree; we need to only search in the right subtree.
  • 16. INSERT OPERATION Inserting a value in the correct position is similar to searching because we try to maintain the rule that the left subtree is lesser than root and the right subtree is larger than root. We keep going to either right subtree depending on the value and when we reach a point left or right subtree is null, we put the new code there.
  • 21. DELETE OPERATION There are three cases for deleting a node from a binary search tree.
  • 22. CASE-1 In the first case, the node to be delete is the leaf node. In such a case, simply delete the node from the tree.
  • 23. CASE-2 In the second case, the node to be deleted lies has a single child node. In such cases follow the step below 1.Replace that node with its child node. 2.Remove the child node from its original position.
  • 25. CASE-3 • In the third case, the node to be deleted has two children. In such a case follow the steps below: 1.Get the inorder successor of that. 2.Replace the node with the inorder successor. 3.Remove the inorder successor from its original position.
  • 28. PRESENTED BY: •Ehsan ul khaliq (F20-BsCS-5004) •Faisal Shehzad (F20-BsCS-5030) •Kamran Zafar (F20-BsCS-5039)