What is a Binary Search Tree (BST)?

This lesson will introduce the Binary Search Trees and their properties.

Introduction

In Binary Search Tree, the values of nodes in the left sub-tree should be equal to or less than the value of the current node. Similarly, the values of all the nodes in the right sub-tree 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

Let’s see a few examples of BSTs

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