Você está na página 1de 2

ECE 242 Project 4

Prof. Tilman Wolf and Prof. Lixin Gao Due: Thursday 11/17/11 at 11:30 p.m.

Introduction
In this project assignment, you will implement a program that creates a family tree from a database of individuals. Your program will read in information about individuals (i.e., their name, their parents names, their childrens names, etc.) and connect them together. Once a family tree has been created, your program will traverse the tree to nd out how specic individuals are related to each other.

Overview
For this project, we use a subset of a genealogy database made available by the Old Pendleton District Chapter of the South Caroline Genealogical Society. For each individual, their name and the name of their relatives (father, mother, children, spouse) may be available. Based on this information your program should create a tree that connects these individuals together. The main dierence to the trees that we have used previously are: (1) there is no explicit root (i.e., no single individual from whom all other individuals descent), (2) the tree is not a binary tree, but a general tree since individuals may have any number of children, (3) links in the tree need to be bi-directional so you can traverse it upward or downward. Once the tree has been created, your program should print out how every person with last name Major is related to any person with last name Baker. (There are 154 such pairs.) To do this, your program needs to nd these individuals and then search the tree for a path between each pair. Since the tree has bi-directional links and may have loops, it is important to avoid getting stuck in such a loop during the search. Therefore, your program should implement a hash table that contains the individuals that you have already traversed in your current search. (If your search method reaches an individual that you have previously visited, then it should not continue searching along this path to avoid an innite loop.) When a path is found between the two individuals, all persons along the path should be printed out. If no path can be found, then the program should say so. A hypothetical output for one pair of individuals should look like: Major, John and Baker, Arthur are related: Baker, Arthur (child of) Baker, Myrtle (child of) Smith, Alice (mother of) Baker, Laura (spouse of) Major, John.

Details
The database of individuals is provided in the le Satterfield.txt, which you should put in your project outside the src folder. We provide three classes for reading the individual from the database: Person, PersonReader, and Genealogy. You may change these classes any way you like. For example, you may need to add data structures to Person, so you can make connection between relatives while creating the tree. The database contains data from real people. Thus, the data may be incomplete or inconsistent. There are also multiple people with the same name. You should try to disambiguate as necessary. (For example: An individuals fathers name may match multiple people in the database. In this case, you could check which potential father has the individuals mother listed as their spouse.) 1

The hash table that you need to use while searching for a path through the tree should be implemented in a class named HashTable. The hash table should have methods to insert a person and to check if a particular person has already been entered. There are 430 individuals in the database, so you should make the hash table suciently large (even though it is unlikely that you will visit all 430 individuals in any one search). The search of the relationship between individuals can be done iteratively or recursively. Feel free to program it either way. There may be multiple paths between individuals. It is sucient that you report any one of the existing ones. You may report the path in either direction.

How to Start?
Modify the provided code to read all individuals and store their records in memory. Then, take each individual and try to nd their immediate relatives (father, mother, spouse, children) and store this information in the Person class. If you want to check the correctness of your code manually for some individuals, you open the database le in an editor (or in Excel) and search for entries that contain the individuals name. Once you have created the family tree, then implement the hash table that you need for the search. Each search for a connection between two individuals should start with an empty hash table. All individuals that are visited should be added to the hash table during the search to avoid getting stuck in a loop. Once you nd a path between two individuals, print out the result. Repeat the search for all 7 individuals with last name Major and all 22 individuals with last name Baker (=154 pairs).

Grading
You should submit your complete code in a .zip le on SPARK. This zip le should also contain a le named output.txt that contains the output of your program for one run. You will receive 75 points for your code running correctly and 25 points for the thoroughness and usefulness of the comments included in your code. The breakdown of points is: Program stores individuals: 5 Correct implementation of family tree creation: 30 Correct implementation of HashTable: 15 Correct implementation of search between two individuals: 15 Program prints out correct result: 10 Comments describing your design decisions and how the code operates: 25 Note that all submissions must adhere to the course policies posted on the course web site.

Você também pode gostar