You will then need to create a new empty project with the files BSTreeApplet.html and BSTreeApplet.java . Right click on the files and store them in your folder. (Important note: Make sure when saving BSTreeApplet.html to choose save as "BSTreeApplet.html" with the double quotes.)
Then:
BSTree
class:
public BSTree()
initializes a new tree
public String display()
returns a String with the data fields of the tree in order
private String displayHelper(TreeNode root)
Recursive helper function for display().
public void startInsert(Comparable data)
"starts" the insert operation.
private TreeNode insert(TreeNode root, Comparable data)
inserts data in tree root, preserves BST
public int startCount()
"starts" counting
private int count(TreeNode root)
Recursively counts nodes in tree root.
public boolean startFind(Comparable data)
"starts" the find operation.
public boolean find(TreeNode root, Comparable data)
returns true if data is in tree root, otherwise returns false
public void startDelete(Comparable target)
"starts" the delete operation.
private TreeNode delete(TreeNode node, Comparable target)
if target is in tree node, deletes it by calling deleteTargetNode, otherwise does nothing.
private TreeNode deleteTargetNode(TreeNode target)
target points to node to be deleted, target node is deleted preserving binary search tree property
When you are finished, post your completed applet to your website, and submit the code for the three completed methods to mrsimon@lycos.com: