Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use merge sort Part 2: Sibling Search and Combining Trees (12%, due in Week 11) In this part of the assignment, you will write a

image text in transcribedimage text in transcribed

use merge sort

Part 2: Sibling Search and Combining Trees (12%, due in Week 11) In this part of the assignment, you will write a function for returning more complex relationship information, and a function that takes two potentially overlapping family trees and combines the information into a single database. 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 logn), 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) [] # Part 2: (due Week 11) # def siblings (person, family): Input: 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. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

If you were Rob Whittier, how would you resolve this dispute?

Answered: 1 week ago