A binary tree represents a family tree, where the root is
'me'. The subtrees of the root are
'mother', 'father' etc.
The specification of the tree starts as follows.
class Relative {
String name;
int yearOfBirth;
Relative mother, father;
}
public class FamilyTree {
private Relative root;
public FamilyTree() {
root = null;
}
...
Program the methods for the class (specify their function in error
situations, as well).
- public String oldestAncestor()
returns the name of the ancestor to which the path
is longest from the root (from 'me').
If it is not unique, return some of them.
Estimate the O-class of your operation.
- public void printThoseWhoHaveTraditionalName()
prints all the persons that have exactly the same name as at least
one of her/his ancestors. To print a person here means
printing the name and the year of birth.
Estimate the O-class of your operation.
(8 points)