TreeWorld

advertisement
TreeWorld
For this project we will be working with Gridworld, Collections and Trees. We will be
utilizing GridWorld to implement a binary search tree, and then implementing a Critter
which searches our tree and eats the numbers we search for.
Resources:
http://staffweb.psdschools.org/caleb/treeExercise/TreeRunner.java
http://staffweb.psdschools.org/caleb/treeExercise/BST.java
http://staffweb.psdschools.org/caleb/treeExercise/Fork.java
http://staffweb.psdschools.org/caleb/treeExercise/ForkDisplay.java
http://staffweb.psdschools.org/caleb/treeExercise/Number.java
http://staffweb.psdschools.org/caleb/treeExercise/NumberDisplay.java
http://staffweb.psdschools.org/caleb/treeExercise/SearchCritter.java
http://staffweb.psdschools.org/caleb/treeExercise/TreeNode.java
Download all of these files and put them in the treeExercise package in netbeans.
See next page for exercises
Exercises:
We are building a Tree which will hold the following numbers 65, 32, 55, 97, 102,
4, 16, 70, 5, 28, 43, 66, 81
1) TreeNode: Read the TreeNode.java file, change the type of ‘value’ so that it
matches what we need for this exercise. What type of primitive or object is our
tree going to be?
2) BST: Implement a binary search tree utilizing the classes provided. Create a
tree with the following numbers that looks like the image below.
Numbers: 65,32,55,97,102,4,16,70,5,28,43,66,81
The implementation for you to complete is available in the BST.java file where
you will find descriptions of the methods you need to implement
3) SearchCritter; Implement methods in the SearchCritter class so that it
traverses the tree and finds the number we are searching for. The
SearchCritter.java file has descriptions for you to complete.
Note: This is hard! Ask us for help!
Download