Binary Search Tree

Overview

A binary search tree (BST) is a binary tree satisfying the binary-search-tree property:

Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.keyx.key. If y is a node in the right subtree of x, then y.keyx.key.

Traversals

Consider an arbitrary node x of some BST. Then:

Successors

The successor of a node in a binary search tree is the node whose value would appear immediately after in an in-order traversal.

Predecessors

The predecessor of a node in a binary search tree is the node whose value would appear immediately before in an in-order traversal.

Deletions

Consider deleting node z from a BST. There are three conceptual cases to consider corresponding to the number of children z has:

Powered by Forestry.md