1. Atal Bihari Vajpayee Vishwavidyalaya Bilaspur Chhattisgarh
Session 2025-
26
Guidance By:-
Mr.Jitendra Kumar Sir
Assistant Professor
Presented By:-
Ravindra Singh Rathore
Binary Tree And Its Operation
Subject:- Data StructureAndArchitecture
2. Outline
• Tree
• Binary tree Implementation
• Binary Search Tree
• BST Operations
• Traversal
• Insertion
• Deletion
• Types of BST
• Complexity in BST
• Applications of BST
3. Trees
Tree
• Each node can have 0 or more children
• A node can have at most one parent
Binary tree
• Tree with 0–2 children per node
• Also known as Decision Making Tree
4. Trees
Terminology
• Root no parent
• Leaf no child
• Interior non-leaf
• Height distance from root to leaf (H)
5. Why is h important?
The Tree operations like insert, delete, retrieve etc. are typically
expressed in terms of the height of the tree h.
So, it can be stated that the tree height h determines running
time!
6. Binary Search Tree
Key property is value at node
• Smaller values in left subtree
• Larger values in right subtree
Example
X > Y
X < Z
Y
X
Z
8. Difference between BT and BST
• A binary tree is simply a tree in which each node can have at most
two children.
• A binary search tree is a binary tree in which the nodes are
assigned values, with the following restrictions :
1. No duplicate values.
2. The left subtree of a node can only have values less than the
node
3. The right subtree of a node can only have values greater than the
node and recursively defined
4. The left subtree of a node is a binary search tree.
5. The right subtree of a node is a binary search tree.
9. Binary Tree Search Algorithm
TREE-SEARCH(x,k)
• If x==NIL or k==x.key
• return x
• If k < x.key
• return TREE-SEARCH(x.left,k)
• else
• return TREE-SEARCH(x.right,k)
17. Complexity in BST
Operation Average Worst Case Best Case
Search O(log n) O(n) O(1)
Insertion O(log n) O(n) O(1)
Deletion O(log n) O(n) O(1)
18. Applications of BST
• Used in many search applications where data is constantly
entering/leaving, such as the map and set objects in many
languages' libraries.
• Storing a set of names, and being able to lookup based on a
prefix of the name. (Used in internet routers.)
• Storing a path in a graph, and being able to reverse any
subsection of the path in O(log n) time. (Useful in travelling
salesman problems).
• Finding square root of given number
• allows you to do range searches efficiently.