Computer ScienceData StructuresMedium

Binary Search Tree

Also known as:BSTOrdered binary treeSorted binary tree

A binary search tree (BST) is a binary tree in which every node satisfies the property that all keys in its left subtree are less than the node's key and all keys in its right subtree are greater. This ordering property makes search, insertion, and deletion operations efficient, averaging O(log n) for balanced trees. BSTs are foundational in database indexing, symbol tables, and dynamic set operations.

BST Operation Time Complexities

OperationAverage CaseWorst Case (Skewed)Best Case
SearchO(log n)O(n)O(1)
InsertO(log n)O(n)O(1)
DeleteO(log n)O(n)O(log n)
Find Min/MaxO(log n)O(n)O(1)
In-order TraversalO(n)O(n)O(n)

Interactive Tools

CS USF — BST Visualization

Open Tool

Visualgo — BST

Open Tool

Khan Academy — Binary Search Trees

Open Tool
A binary search tree showing nodes with left children smaller and right children larger

Wikimedia Commons, CC BY-SA

Related Terms

The term "binary search tree" combines "binary" (from Latin "binarius," two) with "search tree," a structure designed for efficient search operations. The concept was formalized in the 1960s by computer scientists developing efficient sorting and retrieval algorithms.

bstsearchtreesortingdata-structurealgorithms