Introduction to Binary Search Tree
Last Updated :
12 Dec, 2024
Improve
Binary Search Tree is a data structure used in computer science for organizing and storing data in a sorted manner. Binary search tree follows all properties of binary tree and for every nodes, its left subtree contains values less than the node and the right subtree contains values greater than the node. This hierarchical structure allows for efficient Searching, Insertion, and Deletion operations on the data stored in the tree.

Properties of Binary Search Tree:
- The left subtree of a node contains only nodes with keys less than the node's key.
- The right subtree of a node contains only nodes with keys greater than the node's key.
- The left and right subtree each must also be a binary search tree.
- There must be no duplicate nodes(BST may have duplicate values with different handling approaches).
Test Your Understanding
Given a Binary Tree, find out if it is Binary Search Tree or not.
Important Points about BST
- A Binary Search Tree is useful for maintaining sorted stream of data. It allows search, insert, delete, ceiling, max and min in O(h) time. Along with these, we can always traverse the tree items in sorted order.
- With Self Balancing BSTs, we can ensure that the height of the BST is bound be Log n. Hence we achieve, the above mentioned O(h) operations in O(Log n) time.
- When we need only search, insert and delete and do not need other operations, we prefer Hash Table over BST as a Hash Table supports these operations in O(1) time on average.
Next Articles:
- Applications, Advantages and Disadvantages of Binary Search Tree
- Insertion in Binary Search Tree (BST)
- Searching in Binary Search Tree (BST)
- Deletion in Binary Search Tree (BST)