Due: 11:59 pm on Wednesday 10/8/2003
For this assignment you must work alone.
For this assignment, you must implement the BSTree class in Smalltalk. This class provides an abstract data type for Binary Search Trees. Recall that in a binary search tree, all values in the left subtree of a node are less than the value in the node and all values in the right subtree of a node are greater than to the value in the node. For this class we will not allow for duplicate values in the tree. Each node will store a single integer value. Your class should define appropriate methods and instance variables for creating, accessing and modifying binary search tree instances.
A GUI is not required for this project; however, up to 10 pts extra credit will be awarded for systems with a menu drriven GUI.
The following messages are to be supported by your class.
This class method returns a new empty binary search tree.
This class method inserts a node into the binary search tree with the value of the node the integer given as the argument. If a node with this value already exists in the tree, display a warning message in a pop-up window and no action is taken.
This class method is to remove a node from the binary search tree that has the value given as the argument. If the node with the value has two children, you are not allowed to do a "lazy delete". Instead you are to exchange the value in the node with the smallest value in that node's right sub-tree and then delete this smallest value from the right sub-tree. If a node with the value given as the argument does not exist in the tree, display a warning message in a pop-up window and no action is taken.
This class method is to return the number of nodes currently in the binary search tree.
This class method is to list all of the values currently stored in the binary search tree. Most of the work for this method should be performed by a method called inFixTraversal.
This class method is to list all of the values currently stored in the binary search tree while showing the form of the tree. Exactly how this information is shown is left up to you.
This class method is to return the height of the node which contains the value given as the arguement. Remember the height of a node is the length of the the longest path from that node to a leaf. All leaves have height of zero. If the argument given is not a node in the tree, return the value of -1.
This class method is to return the depth of the node which contains the calue given as the argument. Remember the depth of a node is the length of the path from the root of the tree to that node. The root has depth of zero. If the argument given is not a node in the tree, return the value of -1.
This class method is to list the values of all nodes in the path starting from the first argument and ending at the second argument. The first argument must be an ancestor (closer to the root) of the second argument for a path to exist. If a path does not exist, display warning message in a pop-up window and no action is taken.
Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.
The work you turn in must be 100% done by your own own. You are not allowed to share code with any other students (inside this class or not). You may discuss the project with other students; however, you may not show any code you write to another student nor may you look at any other student's written code.