Trees

Concept shape

Core
Definition

A BST keeps smaller values on the left and larger values on the right.

Step 1 / 5
Concept shape
Current lesson

Binary Search Trees Lab

Trees Core

Binary Search Trees

Welcome to the Binary Search Trees concept lab. A BST keeps smaller values on the left and larger values on the right. The must know points are: Inorder traversal gives sorted values. Balanced height gives O(log n) search. Unbalanced trees can degrade to O(n). The common operations are: search O(h), insert O(h), delete O(h). The complexity shape is O(h), balanced O(log n), worst O(n). Watch out for these pitfalls: Ignoring duplicates policy. Assuming a tree is balanced automatically. Related algorithms include BST Search, Tree Traversal.

Concept details

A BST keeps smaller values on the left and larger values on the right.

Must know

  • Inorder traversal gives sorted values.
  • Balanced height gives O(log n) search.
  • Unbalanced trees can degrade to O(n).

Complexity

O(h), balanced O(log n), worst O(n)

Open deeper visual structure lesson
1.0x