Question
A file has genealogy data for a collection of N people. The first line of the file contains the integer N followed by the N
A file has genealogy data for a collection of N people. The first line of the file contains the integer N followed by the N additional lines of data. Each of these additional lines specifies a list of the children for a single person. The line starts with the name of the person, followed by the number of that person's children, followed by the names of the children. Here is an example of a file specifying genealogy information for 10 people.
10
AI 3 Beth, Carol, Dino
Beth 1 Pablo
Carol 3 Ben, Alex, Mary
Dino 0
Pablo 2 Angela, Miguel
Ben 0
Alex 0
Mary 0
Angela 0
Miguel 0
For example, AI has three children named Beth, Carol, and Dino; Beth has one child named Pablo; and Dino has no children. You may assume that all names are unique.
Write a program which reads a file of genealogy information and the allows the user to enter pairs of names X and Y. The program then determines whether Y is a descendant of X, and if so, prints a list of the names beginning with X and ending with Y, such as that each person in the chain is a child of a person preceding them on the list. Otherwise, the program states that Y is not descendant of X.
PS: Add comments please so i can understand it better.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started