Hi, this is my first time posting here. My problem is this: I am creating a family tree program that has to use tree that is due Tuesday. Everyone I have talked to on the internet has said has said there are better data structure objects to use than tree, but I don't have a choice in the matter. One major problem I am having is figuring out what tree to use and how it would work. the assignment says use a binary search tree, but the teacher said in class that it doesn't, that it says modify an existing program for a BST he gave us and that it won't be a BST in the end. Irrelevant however, because all the methods he gave as hints all have their own limitations. One suggestion he gave was for people whose ancestors were unknown, you would use a dummy parent in a btree. Problem is, that everytime you had more than 2 nodes on the tree, you would need a new dummy parent. I don't know how to write anything like that, and it would also cause incest, which is not allowed in the assignment. Another method he suggested was to use the children as the top of the tree instead of the bottom. It would the children would be root nodes instead. however, this would cause multiple root nodes and well, it just doesn't seem right. Some previous people have said my teacher's instructions and assignment do not make sense, and I am inclined to believe them, but that is beside the point since this assignment is worth more than 7 times the grade of a quiz, and the teacher thinks he makes perfect sense (and no one else in the class has actually raised these issues with him, making me feel like the only one clueless). I tried several ideas on the tree, but none seemed to work for different reasons(one idea created incest, another made it so that for every 2 nodes without a parent, a dummy node had to be added, another used the children of the parents as the root nodes, but I don't think multi root systems work for trees). I am unsure if this is a beginner thing, but I feel like it is, there was no section for a data structure c++ forum. I learn best by example, with explanations provided in example. I then apply the examples to similar problems. So a tree with similar properties would be the best thing for me to look at. I also need to know how to put the tree in level order, but I think I have that figured out. Another thing is using input from a file or user to fill the tree, but I think I have that down also. I just don't know how to create a tree with the properties needed. Any examples, explanations, etc. would be appreciated.
OK as I understand the assignment: need a data structure to completely hold the family tree of a specified amount of generations. Variable amount of kids but always 2 parents. I'm not sure but a bidirectional tree maybe? Or a binary tree containing a linked list for siblings:
Option 1:
struct person {
char *name;
person *father;
person *mother;
person *significant other;
person *kids[];
};
Option 2:
struct person {
char *name;
person *father;
person *mother;
person *significant other;
person *sibling;
person *kids[];
};
Possible Option 3:
struct person {
char *name;
person *father;
person *mother;
person *significant other;
person *oldersibling;
person *youngersibling;
person *kids[];
};
What your teacher is suggesting doesn't sound possible without a hybrid of data structures.