Problem Directory: /home/bvanderz/cs140/Labs/treeFind
Problem Description
Write a recursive find function for a binary search tree that is implemented according to the course's online notes. That means that each leaf's left and right children point to the sentinel node, not to NULL. Also all leafs point to the same sentinel node, which is the same sentinel node whose right child points to the root of the tree. You can use the iterative BSTree::Find function from the online course notes to help you with writing the recursive function.
Here is some sample data. The "done" marks the end of the names to be inserted into the tree. We have provided code to read these name/gpa pairs and insert them into the tree. The remaining input consists of names to be found. Again we have provided code that reads these names and calls the BSTree::Find function, which in turn calls the recursive_find_helper function that you will be writing.
Martha 3.5
Smiley 3.57
Bulldog 2.2
Hound 2.5
Labradoodle 1.5
Cocker 3.5
Terrier 4.0
done 0
Hound
Chuck
Martha
Smiley
Cocker
Nancy
Zachary
Terrier
Bulldog
Labradoodle
Alfred
What To Do
- You will modify the file named treeFind.cpp. Put your function
definition where the comment tells you to do so.
- Compile your file into an executable named "treeFind".
- There is an input file named input1.txt.
You can test your program by using this file as input to your program.
- There is an executable named "solution" that you can use to see
the correct output. An example execution would be:
./solution < input1.txt
- You can run the "gradeall" script to see if your program passes
the test cases.
- Get a TA to check you off when your function correctly passes the
test cases.