logo
SEE ALGORITHMS
    Bubble Sort
    Insertion Sort
    Selection Sort
    Heap Sort
    Radix Sort
    Merge Sort
    Quick Sort

Binary Search Tree

A Binary Search Tree (BST) is like a well-organized library where each book (node) has a clear place based on its value. In a BST, each node has up to two children: the left child holds smaller values, and the right child holds larger values. This structure allows for efficient searching, adding, and removing of books, as you can quickly navigate left or right to find or insert a book in its proper place.

How it Works

  • Insertion walks down the tree by repeatedly choosing left or right based on comparison, stopping only when it finds an empty spot. The new node is attached as a leaf.
  • Deletion first locates the target node, then carefully reconnects its children so the BST rule still holds. If the node has no children, it is simply removed. If it has one child, that child takes its place. If the node has two children, the tree replaces it with a nearby node that preserves ordering.

Curious to Learn More?

Hand-picked resources to deepen your understanding

Beginner Friendly
Grokking Algorithms

A friendly, fully illustrated guide. The best starting point for visual learners.

Practical Guide
A Common-Sense Guide to Data Structures and Algorithms

A practical guide with clear explanations and real-world examples.

Deep Dive
Introduction to Algorithms

The definitive guide (CLRS). Comprehensive and rigorous, perfect for deep diving into theory.

As an Amazon Associate, I earn from qualifying purchases. This helps support the site at no extra cost to you.

© 2025 SEE Algorithms. Code licensed under MIT, content under CC BY-NC 4.0.