I have a hash table of nodes basically, and each node has the index of of its parents (mom and dad) or -1 if it does not have one. My assignment is to find the youngest comment ancestor of two people. I already have my family tree stored into a hash table data structure but now I want to store the lineage (going up) of each person, given 2 ppl into 2 separate arrays and sort them based on year so that I can return the youngest match. Does anyone have any idea on how to do this? or have any better ideas? I was thinking of using a tree traversal because it basically was like a tree or am I wrong?
Thank you very much!
Aucun commentaire:
Enregistrer un commentaire