Red/Black Tree Demonstration: Maintenance Version


Usage: Type an integer into the text field. Click on the Add Node button or type the letter 'a' to begin insertion of a node with the specified integer value. Click on the Next Step button or type the letter 'n' to see what happens on the next iteration of insertion. Click on the Restart button or type the letter 'r' to start from an empty tree. To delete a node, click on the Delete Node button or type the letter 'd', then click on the node you wish to delete. The node should turn green. Click on the Next Step button or type the letter 'n' repeatedly to see the steps involved in deleting the node. Click on the Undo button or type the letter 'u' to restore the tree to its state before the last node was inserted or deleted. Click on a node then click on the Color It button to reverse its color but watch it because trying to add to or delete from a non-red-black tree may have unpredictable results. See

      Berman and Paul. Algorithms: Sequential, Parallel, and Distributed.
      Thomson Course Technology, 2005 (ISBN:0-534-42057-5).

for a description of the set of rules of insertion and deletion which the code follows.

Quick add: This is a new feature. Type an integer into the textfield and hit return. The new object will be inserted into the red-black tree without having to hit the Next button at all.

Source Code: The source code shows how to start the applet with a pre-built tree. RedBlack.java. You also need Stream.java and TokenObject.java.