A file has genealogy data for a collection of N people. The first line of the file
Question:
A file has genealogy data for a collection of N people. The first line of the file contains the integer N followed by N additional lines of data. Each of these additional lines specifies a list of 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 ten people.
10
Ben 3 Anna Sam Eddy
Anna 1 Pierre
Sam 3 Nasrine Alex Mary
Eddy 0
Pierre 2 Rita Miguel
Nasrine 0
Alex 0
Mary 0
Rita 0
Miguel 0
For example, Ben has three children named Anna, Sam, and Eddy; Anna has one child named Pierre; and Eddy has no children. You may assume that all names are unique.
Implement a program which reads a file of genealogy information and then 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 names beginning with X and ending with Y, such that each person in the chain is a child of person preceding them on the list. Otherwise, the program states that Y is not a descendant of X.
Example: Mary descendant of Ben? Program will display "BenàSamàMary"
Rita descendant Eddy? Program will display "Rita is not a descendant of Eddy"
Your program should use Stack
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill