SlideShare a Scribd company logo
4
Most read
5
Most read
9
Most read
Binary Search Tree in Data
Structures
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
Introduction
 A binary search tree is a useful data structure for fast
addition and removal of data.
 It is composed of nodes, which stores data and also
links to upto two other child nodes.
 It is the relationship between the leaves linked to and
the linking leaf, also known as the parent node, which
makes the binary tree such an efficient data structure.
Cont…
 For a binary tree to be a binary search tree, the data of
all the nodes in the left sub-tree of the root node
should be less than the data of the root.
 The data of all the nodes in the right subtree of the
root node should be greater than equal to the data of
the root.
 As a result, the leaves on the farthest left of the tree
have the lowest values, whereas the leaves on the right
of the tree have the greatest values.
Binary Search Tree
Insertion in a BST
 To insert data into a binary tree involves a function
searching for an unused node in the proper position in
the tree in which to insert the key value.

 The insert function is generally a recursive function
that continues moving down the levels of a binary tree
until there is an unused leaf in a position which
follows the following rules of placing nodes.
Cont..
 Compare data of the root node and element to be
inserted.
 If the data of the root node is greater, and if a left
subtree exists, then repeat step 1 with root = root of
left subtree. Else,
 Insert element as left child of current root.
Cont..
 If the data of the root node is greater, and if a right
subtree exists, then repeat step 1 with root = root of
right subtree.
 Else, insert element as right child of current root.
BST Insertion
Assignment
 Explain Binary Search Tree in data structure with
suitable example and discuss basic operation.

More Related Content

What's hot (20)

PDF
Binary tree
Rajendran
 
PPTX
Binary Heap Tree, Data Structure
Anand Ingle
 
PPTX
Queues
Ashim Lamichhane
 
PPT
Lec 17 heap data structure
Sajid Marwat
 
PPT
1.7 avl tree
Krish_ver2
 
PPT
Binary search tree(bst)
Hossain Md Shakhawat
 
PDF
Queue as data_structure
eShikshak
 
PPTX
DFS and BFS
satya parsana
 
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
PPTX
Data structure - Graph
Madhu Bala
 
PDF
Binary search tree operations
Kamran Zafar
 
PPT
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
PPT
data structure
hashim102
 
PPT
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
PPTX
Data Structures (CS8391)
Elavarasi K
 
PPTX
Tree Traversal
Md. Israil Fakir
 
PPT
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
PPSX
Data structure stack&queue basics
Selvin Josy Bai Somu
 
Binary tree
Rajendran
 
Binary Heap Tree, Data Structure
Anand Ingle
 
Lec 17 heap data structure
Sajid Marwat
 
1.7 avl tree
Krish_ver2
 
Binary search tree(bst)
Hossain Md Shakhawat
 
Queue as data_structure
eShikshak
 
DFS and BFS
satya parsana
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Data structure - Graph
Madhu Bala
 
Binary search tree operations
Kamran Zafar
 
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
data structure
hashim102
 
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
Data Structures (CS8391)
Elavarasi K
 
Tree Traversal
Md. Israil Fakir
 
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
Data structure stack&queue basics
Selvin Josy Bai Somu
 

Similar to Binary search tree in data structures (20)

PDF
binarysearchtreeindatastructures-200604055006 (1).pdf
ajajkhan16
 
PPTX
Data- Structures-Binary-Search-Trees.pptx
selvi653915
 
PPTX
Introduction-to-Trees-in-Data-Structures-and-Algorithms[1].pptx
skhacharia305
 
PPTX
Binary search tree definition operation.pptx
jeevananandk28
 
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
VISWANATHAN R V
 
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
kncetaruna
 
PDF
Tree
maamir farooq
 
PPTX
nptel 2nd presentation.pptx
KeshavBandil2
 
PPTX
9e28d06f-bae9-487e-8360-0e2c0a8c2972.pptx
alagark070605
 
PDF
Unit iv data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
PPTX
Trees data structure
Mahmoud Alfarra
 
PPT
Algorithm and Data Structure - Binary Trees
donotreply20
 
PPTX
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
deivasigamani9
 
PPTX
Database Engine
prashanthbabu07
 
DOCX
Biary search Tree.docx
sowmya koneru
 
PPT
Chapter 8: tree data structure
Mahmoud Alfarra
 
PDF
Makalah if2091-2011-020
Satria Ady Pradana
 
PDF
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
PPTX
binary search tree
Halabja university - Kurdistan -Iraq
 
binarysearchtreeindatastructures-200604055006 (1).pdf
ajajkhan16
 
Data- Structures-Binary-Search-Trees.pptx
selvi653915
 
Introduction-to-Trees-in-Data-Structures-and-Algorithms[1].pptx
skhacharia305
 
Binary search tree definition operation.pptx
jeevananandk28
 
UNIT III Non Linear Data Structures - Trees.pptx
VISWANATHAN R V
 
UNIT III Non Linear Data Structures - Trees.pptx
kncetaruna
 
nptel 2nd presentation.pptx
KeshavBandil2
 
9e28d06f-bae9-487e-8360-0e2c0a8c2972.pptx
alagark070605
 
Unit iv data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
Trees data structure
Mahmoud Alfarra
 
Algorithm and Data Structure - Binary Trees
donotreply20
 
4. Apply data structures such as arrays, linked lists, and trees as an abstra...
deivasigamani9
 
Database Engine
prashanthbabu07
 
Biary search Tree.docx
sowmya koneru
 
Chapter 8: tree data structure
Mahmoud Alfarra
 
Makalah if2091-2011-020
Satria Ady Pradana
 
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Ad

More from chauhankapil (20)

PPTX
Gray level transformation
chauhankapil
 
PPTX
Elements of visual perception
chauhankapil
 
PPTX
JSP Client Request
chauhankapil
 
PPTX
Jsp server response
chauhankapil
 
PPTX
Markov decision process
chauhankapil
 
PPTX
RNN basics in deep learning
chauhankapil
 
PPTX
Introduction to generative adversarial networks (GANs)
chauhankapil
 
PPTX
Bayesian probabilistic interference
chauhankapil
 
PPTX
Jsp
chauhankapil
 
PPTX
Exception handling in java
chauhankapil
 
PPTX
Knowledge acquistion
chauhankapil
 
PPTX
Knowledge based system
chauhankapil
 
PPTX
Introduction of predicate logics
chauhankapil
 
PPTX
Types of inheritance in java
chauhankapil
 
PPTX
Representation of syntax, semantics and Predicate logics
chauhankapil
 
PPTX
Inheritance in java
chauhankapil
 
PPTX
Propositional logic
chauhankapil
 
PPTX
Constructors in java
chauhankapil
 
PPTX
Methods in java
chauhankapil
 
PPT
Circular linked list
chauhankapil
 
Gray level transformation
chauhankapil
 
Elements of visual perception
chauhankapil
 
JSP Client Request
chauhankapil
 
Jsp server response
chauhankapil
 
Markov decision process
chauhankapil
 
RNN basics in deep learning
chauhankapil
 
Introduction to generative adversarial networks (GANs)
chauhankapil
 
Bayesian probabilistic interference
chauhankapil
 
Exception handling in java
chauhankapil
 
Knowledge acquistion
chauhankapil
 
Knowledge based system
chauhankapil
 
Introduction of predicate logics
chauhankapil
 
Types of inheritance in java
chauhankapil
 
Representation of syntax, semantics and Predicate logics
chauhankapil
 
Inheritance in java
chauhankapil
 
Propositional logic
chauhankapil
 
Constructors in java
chauhankapil
 
Methods in java
chauhankapil
 
Circular linked list
chauhankapil
 
Ad

Recently uploaded (20)

PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 

Binary search tree in data structures

  • 1. Binary Search Tree in Data Structures Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2. Introduction  A binary search tree is a useful data structure for fast addition and removal of data.  It is composed of nodes, which stores data and also links to upto two other child nodes.  It is the relationship between the leaves linked to and the linking leaf, also known as the parent node, which makes the binary tree such an efficient data structure.
  • 3. Cont…  For a binary tree to be a binary search tree, the data of all the nodes in the left sub-tree of the root node should be less than the data of the root.  The data of all the nodes in the right subtree of the root node should be greater than equal to the data of the root.  As a result, the leaves on the farthest left of the tree have the lowest values, whereas the leaves on the right of the tree have the greatest values.
  • 5. Insertion in a BST  To insert data into a binary tree involves a function searching for an unused node in the proper position in the tree in which to insert the key value.   The insert function is generally a recursive function that continues moving down the levels of a binary tree until there is an unused leaf in a position which follows the following rules of placing nodes.
  • 6. Cont..  Compare data of the root node and element to be inserted.  If the data of the root node is greater, and if a left subtree exists, then repeat step 1 with root = root of left subtree. Else,  Insert element as left child of current root.
  • 7. Cont..  If the data of the root node is greater, and if a right subtree exists, then repeat step 1 with root = root of right subtree.  Else, insert element as right child of current root.
  • 9. Assignment  Explain Binary Search Tree in data structure with suitable example and discuss basic operation.