Question: in python Task A: Siblings (5 Marks) Implement a function siblings (person, family) with the following specification. Input: A string containing a person's name, person,

 in python Task A: Siblings (5 Marks) Implement a function siblings

in python

Task A: Siblings (5 Marks) Implement a function siblings (person, family) with the following specification. Input: A string containing a person's name, person, and a family tree database family as specified above. Output: A list containing the names of all siblings, both half and full, of person that are stored in the database. Your function implementation must have a worst-case time complexity of O(n log n), where n is the size of the input database. For example: >>> duck_tree = [['Donald Duck', 'Quackmore Duck','Hortense McDuck'], ['Della Duck', 'Quackmore Duck', 'Hortense McDuck'], ['Hortense McDuck', 'Fergus McDuck', 'Downy ODrake'], [Scrooge McDuck', None, 'Downy ODrake'], ['Fergus McDuck', 'Dingus McDuck', 'Molly Mallard'], ['Huey Duck', None, Della Duck'], ['Dewey Duck', None, 'Della Duck'), ['Louie Duck', None, Della Duck']] >>> siblings ('Della Duck', duck_tree) ['Donald Duck'] >>> sorted (siblings ('Louie Duck', duck_tree)) ['Dewey Duck', 'Huey Duck'] >>> siblings('Scrooge McDuck', duck_tree) ['Hortense McDuck'] >>> siblings('Fergus McDuck', duck_tree) >>> siblings('Daisy Duck', duck_tree)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!