What is a Binary Search Tree (BST)?

An introduction to the “binary search trees” and their properties.

Introduction

In a binary search tree (BST), the values of nodes in the left-subtree should be equal to or less than the value of the current node. Similarly, the values of all the nodes in the right-subtree should be equal to or greater than the value of the current node.

NodeValues(leftsubtree)<=CurrentNodeValue<=NodeValues(rightsubtree)NodeValues(left subtree)<=CurrentNodeValue<=NodeValues(right subtree)

Examples

See a few examples of BSTs:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.