Binary Search Trees
Binary Search Trees
BINARY SEARCH
TREES
By:-
CHARANPREET KAUR
BINARY SEARCH TREE
In a binary tree, every node can have
maximum of two children but there is no
order of nodes based on their values.
In binary tree, the elements are
arranged as they arrive to the tree, from
top to bottom and left to right.
A binary tree has the following time
complexities...
Search Operation - O(n)
Insertion Operation - O(1)
Deletion Operation - O(n)
To enhance the performance of binary
tree, we use special type of binary
tree known as Binary Search Tree.
Binary search tree mainly focus on
the search operation in binary tree.
Binary search tree can be defined as
follows...
In a binary search tree, all the nodes
in left subtree of any node contains
smaller values and all the nodes in
right subtree of that contains larger
values as shown in following figure...
EXAMPLE
The following tree is a Binary Search Tree. In
this tree, left subtree of every node contains
nodes with smaller values and right subtree
of every node contains larger values.