# Binary Search Tree (BST)

> A binary tree kept in order. Small values go left; big ones go right.

**Field:** Software Development  
**Category:** Algorithms & Data Structures  
**Also known as:** BST, Binary Search Trees, Ordered Binary Tree

## Think of it like

Think of it like a guessing game. Too high, go left; too low, go right.

## Definition

A binary search tree is a binary tree that keeps its values in order. Everything in a node's left branch is smaller than it, and everything in its right branch is bigger. To find a value, you start at the root and go left or right at each step. If the tree stays balanced, that takes about 20 steps for a million values. If it grows lopsided, it can become as slow as a list.

## Example

Emma stores 1,000,000 scores in a balanced search tree. Finding one score takes about 20 steps instead of a million.

## Why it matters

It gives fast search and keeps items sorted at the same time. Many database indexes use a close cousin of it.

## Common mistake

Adding values that are already sorted to a plain search tree. It grows into one long line, and every search becomes slow.

## Three principles

- **Left is smaller.** Right is bigger.
- **Fast search.** When it stays balanced.
- **Keeps order.** Read it left to right.

## Related terms

- [Binary Tree](https://learn.benibix.com/term/development/binary-tree)
- [Binary Search](https://learn.benibix.com/term/development/binary-search)
- [Tree (Data Structure)](https://learn.benibix.com/term/development/tree)
- [Database Index](https://learn.benibix.com/term/development/database-index)

## Told apart from

- [Heap vs Binary Search Tree (BST)](https://learn.benibix.com/compare/heap-vs-binary-search-tree): People think a heap keeps its items sorted, like a binary search tree. It does not. A search tree keeps every value in order, so you can find any one fast. A heap only keeps the smallest item on top. Pick a heap when you only need the next smallest, and a search tree to look up any value.

---

Source: https://learn.benibix.com/term/development/binary-search-tree
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
