What is a binary search tree?

Searching Algorithms Questions Medium



24 Short 58 Medium 71 Long Answer Questions Question Index

What is a binary search tree?

A binary search tree (BST) is a type of binary tree data structure in which each node has a key value and satisfies the following properties:

1. The key value of every node in the left subtree is less than the key value of the node itself.
2. The key value of every node in the right subtree is greater than the key value of the node itself.
3. The left and right subtrees of every node are also binary search trees.

In simpler terms, a binary search tree is a hierarchical structure where each node has a value and two child nodes (left and right). The left child node contains a value smaller than the parent node, while the right child node contains a value greater than the parent node. This property allows for efficient searching, insertion, and deletion operations.

Binary search trees are commonly used in computer science and are particularly useful for efficient searching algorithms. The binary search property allows for a logarithmic time complexity for search operations, making it an efficient data structure for storing and retrieving data in sorted order.