Binary Search Tree
 Binary Search tree can be defined as a class of binary trees, in which the nodes are arranged in a specific order. This is also called ordered binary tree.
 In a binary search tree, the value of all the nodes in the left subtree is less than the value of the root.
 Similarly, value of all the nodes in the right subtree is greater than or equal to the value of the root.
 This rule will be recursively applied to all the left and right subtrees of the root.
A Binary search tree is shown in the above figure. As the constraint applied on the BST, we can see that the root node 30 doesn't contain any value greater than or equal to 30 in its left subtree and it also doesn't contain any value less than 30 in its right subtree.
Advantages of using binary search tree
 Searching become very efficient in a binary search tree since, we get a hint at each step, about which subtree contains the desired element.
 The binary search tree is considered as efficient data structure in compare to arrays and linked lists. In searching process, it removes half subtree at every step. Searching for an element in a binary search tree takes o(log_{2}n) time. In worst case, the time it takes to search an element is 0(n).
 It also speed up the insertion and deletion operations as compare to that in array and linked list.
Q. Create the binary search tree using the following data elements.
43, 10, 79, 90, 12, 54, 11, 9, 50
 Insert 43 into the tree as the root of the tree.
 Read the next element, if it is lesser than the root node element, insert it as the root of the left subtree.
 Otherwise, insert it as the root of the right of the right subtree.
The process of creating BST by using the given elements, is shown in the image below.
Operations on Binary Search Tree
There are many operations which can be performed on a binary search tree.
SN 
Operation 
Description 
1 
Searching in BST 
Finding the location of some specific element in a binary search tree. 
2 
Insertion in BST 
Adding a new element to the binary search tree at the appropriate location so that the property of BST do not violate. 
3 
Deletion in BST 
Deleting some specific node from a binary search tree. However, there can be various cases in deletion depending upon the number of children, the node have. 
Program to implement BST operations
Output:
Enter value to be inserted? 10
Enter value to be inserted? 20
Enter value to be inserted? 30
Enter value to be inserted? 40
Enter value to be inserted? 5
Enter value to be inserted? 25
Enter value to be inserted? 15
Enter value to be inserted? 5
5 5 10 15 20 25 30 40
5 5 15 20 25 30 40
