Search⌘ K

What is a Binary Search Tree (BST)?

Explore what a Binary Search Tree (BST) is, focusing on its node ordering rules and how it differs from a regular Binary Tree. Understand the BST property where left subtree values are less than or equal to the node and right subtree values are greater. This lesson prepares you to implement basic BST operations essential for coding interviews.

Introduction

A Binary Search Tree, also known as an ordered Binary Tree, is a variant of a Binary Tree with a strict condition based on node value.

For all the nodes in a BST, the values of all the nodes in the left sub-tree of the current node are less than or equal to the value of the node itself. All the node values in the right subtree are greater than the value of the current node. This is referred to as the BST rule.

NodeValues(LeftSubtree)<=CurrentNodeValue<NodeValues(RightSubTree)NodeValues(LeftSubtree)<=CurrentNodeValue<NodeValues(RightSubTree) ...