A Binary Search Tree is a tree that follows some order to arrange the elements, whereas the binary tree does not follow any order. In a Binary Search Tree, the value of the left node must be smaller than the parent node, and the value of the right node must be greater than the parent node.
- Searching becomes very efficient in a binary search tree since, we get a hint at each step, about which sub-tree contains the desired element.
- The binary search tree is considered an efficient data structure in comparison to arrays and linked lists. Within respect to searching, the data structure allows us to remove half a sub-tree at every step. Searching for an element ina binary search tree takes O(log n) time. In its worst case, the time it takes to search an element is O(n).
- It also speeds up the insertion and deletion operations in comparison to arrays and linked lists.
Implementation of Binary Search Tree
- Creation
- Searching
- Insertion
- Deletion
- Printing (Preorder, Inorder, Postorder)