This interactive example
lets you experiment with a Binary Tree. A binary tree is a Data
Structure which can be used for high speed searches.
key of all nodes < key of root < key of all nodes
in left subtree node in right subtree.
After watching the tree being built a few
times and trying to work out where the Next Item will be
inserted, try this:
Press the Reset button and enable High Speed. Notice the tree
may get lop sided.
Enable the Balance button. Notice the tree stays balanced:
equal number of nodes to the left and right of the root node of
every sub-tree.
Choose "Ordered List" from the Menu marked "Random List" (the
tree is still being balanced). Note that the items are inserted
into the tree in numerical order and so the tree has to be
rebalanced each time - the root node is changed at every
insertion.
Now disable the Balance button. Note that the tree becomes
extremely lopsided. Inserting ordered items into a tree produces
this worse case scenario!
You can turn off "Auto Growing" and use the Next button to
interactively check where the Next Item will be inserted.
To enter your own list of numbers, select "user defined" from
the choice box that initially says "random list." A text field
should appear. Enter a string of numbers into that text field and
the example will cycle through those numbers.
The list of numbers can be separated by any non-digit
characters. (Including decimal points, so "15.8" would be
considered as the separate numbers, "15" and "8"). Only numbers
between 0 and 100 will be used. If 12567 were entered, the
example would use 67.
If anyone finds any problems with the Binary Tree Viewer,
please e-mail them to the author of this applet: Michael Woodson
n9442097@fozzie.cc.wwu.edu.