



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Goal: The purpose of this assignment is to learn to use AA Trees to implement the Dictionary ADT.
Objectives: be able to write code to implement insertion into an AA Tree; be able to write code to implement lookup in an AA Tree; be able to write code using the strcmp function.
Write a program phonebook2 that will read in a file containing pairs of lines names and phone numbers, place those into an AA Tree. and then read in a list of names (one per line) from the standard input. For each name read from the standard input, the program should determine if there is an exact match in the AA Tree. If there is a match it should print out the name, followed by the phone number. If there is not a match, it should print out the name followed by the string "NoÃmatchÃfound.".
The program should work with input and produce output exactly as described here. (Automated tools that do a character by character comparison may be used for grading.) For inputs that do not comply with this specification, your program may print an error message and exit; there should not be any inputs which would cause your program to have undefined behavior.
phonebook2 command line. The program executable should expect as a command-line argument the name of a file containing a list of phone numbers. Example:
./ phonebook2 Ã phonelist. txt
data file. The file specified on the command-line (e.g., phonelist.txt) will contain lines of up to 80 non-null characters. (If there are more than 80 -characters—not counting '\n'—on a line, the additional characters should be silently discarded, producing the same result as if all of the lines were truncated to 80 characters.)
Each pair of lines will represent one ‘phonebook entry’. The text of odd lines will be considered to be a person’s name. The text of even lines will be considered to be the phone number of the person named on the previous line. The program should treat these items as uninterpreted strings of up to 80 non-null characters. (In particular the program should not not try to parse the name to determine the last name or parse the the phone number to encode the individual digits.) The entries will not necessarily be sorted in any way.
An example data file is:
John à Smith +49 à 1234 à 5 - Jeff 458 - Abe à Lincoln 1 -888 - WIT - HOUS
Standard Input. The program should interpret each line on the standard input as a name that it should attempt to find in the list. (If there are more than 80 -characters + '\n' on a line, the additonal characters should be discarded.) The program should stop when it sees a blank input line or EOF.
An example of some input to the program would be:
Jeff Dr. à von à Ronne Supe r c a l i f ragilisticexpialidoc i ous John à Smith Abe Jeffery
Bubba
For testing, you may wish to redirect the input from files containing lists of names such as that found in this example.
Standard Output. For each of the lines on the standard input, the program should attempt to find a phonebook entry who’s name is an exact match of the name in the standard input line. If there is a match, the program should output the name, a colon and space, and then the phone number on a single line. If there is no match, it should output the name, a colon, and the text, "NoÃmatchÃfound.".
The output for the example inputs listed above would be:
Jeff : à 458 - Dr. à von à Ronne : à No à match à found. Supe r c a l i f ragilisticexpialidoc i ous : à No à match à found. John à Smith : à +49 à 1234 à 5 - Abe : à No à match à found. Jeffery : à No à match à found.
The specification above is identical to that of assignment 5 , but in this assignment you should store the names and numbers of the phonebook entries into an AA Tree data using the name string as a key and the number string as the value. You should use the ordering provided strcmp to compare keys in your AA Tree implementation. Insertion and lookup should be implemented
Below this statement, please write your name and date.
Use svn to commit your final submission by 5 pm on the due date.
Permissible Collaboration and Resources. This assignment is to be completed individually. You are allowed to discuss general strategies for solving assignments with fellow students or other in- dividuals, but it is no longer a ‘general strategy’ if the discussion gets to the level of detail of what would be done in actual lines of code found in your programs. In addition, discussions of ‘general strategy’ should not be taking place while either party is editing their source code. (It is, however, perfectly acceptable to discuss C language constructs and concrete examples of them which are not taken directly from anyone’s solution to an assignment.) In addition, you may seek more specific help from mentors and lab tutors in trying to understand why their code doesn’t work. Furthermore, you may also seek help and guidance of any kind from the TA and instructor.
For this assignment, you may consult, in addition to any example code or notes provided by the instruction, the following resources:
You may not, however, consult any C code implementing an AA Tree with string keys.