Red/Black Tree Demonstration

Usage:
Type an integer into the text field. Click on the Add Node
button to begin insertion of a red node with the specified integer
value. Click on the Next Step button to see what happens on
the next iteration of insertion. Click on the Restart button
to start from an empty tree. To delete a node, click on the Delete
Node button, then click on the node you wish to delete. The node
should turn green. Click on the Next Step button repeatedly to
see the steps involved in deleting the node. The delete feature is
not fully tested and some deletions may result in trees that lose
their red/black properties. Please report problems to
franco@gauss.ececs.uc.edu.
Click on the Undo button to
restore the tree to it's state before the last node was inserted or
deleted. See any elementary data structures text for a description
of the rules of insertion and deletion including rotation and color
reversals.

Red/Black Trees: These are binary trees
with the following properties.

Every node has a value.

The value of any node is greater than the value of its left child and less
than the value of its right child.

Every node is colored either red or black.

Every red node that is not a leaf has only black children.

Every path from the root to a leaf contains the same number of black
nodes.

The root node is black.

An n node red/black tree has the property that its height is
O(lg(n)). Another important property is that a node can be
added to a red/black tree and, in O(lg(n)) time, the tree can
be readjusted to become a larger red/black tree. Similarly, a node
can be deleted from a red/black tree and, in O(lg(n)) time,
the tree can be readjusted to become smaller a red/black tree.
Due to these properties, red/black trees are useful for data storage.

Insertion: The rules for readjustment when
inserting depend on the concept of rotation.