Your cart is currently empty!
For this lab you are to work in teams of two with the following rules: The two of you will sit together and use one computer. You will both enroll yourself into the same team on Blackboard. Each person must be typing on the keyboard for approximately 50% of the time – the easiest way…
For this lab you are to work in teams of two with the following rules:
Using this struct that we have been working with in class:
struct Bnode{
string data;
Bnode * left;
Bnode * right;
};
Create a little program that is able to build a binary search tree from the names listed in the file, names.txt, which is available in ~jdolan/cs2401/labs/lab14 or in Blackboard.
In the same directory, or on Blackboard, you will find a source file containing some functions and definitions that are very useful for this lab. They appear in the file btreelab.cc.
You can use the inorder traversal that I have given you to see that the names are in there.
Now write a function that searches for and counts the number of times that a particular name occurs. Let the user input the name from the keyboard. (A description of the algorithm for this appears in your book on p. 523 and is printed on the reverse side of this lab paper. The output for the function should just say: “Your search name appears 5 times.” With the number being correct, of course.
CHANGE TYPISTS
Finally write a function that counts the number of names (not unique names) that in the tree and greater than (i.e. come after in the alphabet) the search name. This later function will work better if it is done recursively. Think of it like this:
Submit a copy of your source code, along with a script that looks for the names “Matthew” and “Jessica.”