Question: Task B: Combine Trees (7 Marks) Implement a function combine tress (fl. 12) with the following specification Input: Two family tree databases, 11 and 12.
Task B: Combine Trees (7 Marks) Implement a function combine tress (fl. 12) with the following specification Input: Two family tree databases, 11 and 12. Output: A new family tree database, sorted by name, that combines f1 and 12 together, merging any duplicate entries, or None if there is some conflict that prevents the two data from being merged. For example say we have the following two databases, duck tree and duck tree2, which contain overlapping information: >>> duck_tree - [Donald Duck'. Quacinore Duck', 'Hortense McDock'). Della Duck'. 'Quackmore Duck, Hortense McDuck'). [Hortense McDuck'. 'Fergus McDuck Downy Drake'). tScrooge McDuck'. None, Downy Drake'). Hey Duck', Mone, Della Duck'). [Dewey Duck'. None, Della Duck'). ('Loule Duck None, Della Duck')) >>> dock_tree2 - [[Scrooge McDuck', 'Fergus McDock'. None). [Matilda McDuck', 'Fergus McDuck Downy Drake'). C'Hortense McDock', 'Fergus McDuck', 'Downy Draket). ['Fergus McDuck', 'Dingus McDuck'. 'Molly Mallard']) Then the combine tree function should behave as follows: >>>> combine trees(dock tree, dock tree2) [['Della Duck', 'Quackere Duck', 'Hortense McDuck')'Dewey Duck', None, Della Duck'). 'Donald Duck', 'Quacinore Duck', 'Kortesse McDuck'), ('Fergus McDock'. 'Dingus McDuck'. Molly Mallard')'Hortense McDuck', 'Fergus McDuck', 'Downy Drake'). Hoey Duck. So, *Della Dack'). Leste Dock, Hone. 'Della Duck'). Matilda McDock'. Pergus McDuck Downy Drake'. 'Scrooge McDuck', 'Pergus McDuck', 'Dovy Drake'] Note, in the above example: the identical entries for "Hortense McDuck" bave been metged so that only a single entry is in the output databand the non-idential but non-conflicting entries for Scrooge McDuck' have been med to retain themes Imum amount of information (Scrooge's mother and other are both recorded in the output data whereas in each of the input data mente parat w model) The two input databases should ruin unchanged after function execution Thut, alter calling the function, we still have >>> duck, tree [CDonald Duck'. Quackere DeckHortense Metruck'). [Della Duck. Quackmore Duck. Hortense McDuck'). Hortense McDock', 'Fergus McDuck''Domy Drake'). [Scrooge McDuck, None. Downy brake). CHuey Duck, Nose Della Duck'), 'Dewey Duck', None, Bella Duck'). Louie Duck, Hone, Della Duck"}} >>> dock tree2 [Scrooge McDuck', 'Fergus McDuck, None). Matilda McDuck', 'Fergus McDuck', Downy Drake'). C'Hortense McDuck'. 'Fergus McDuck'. Doway Drake). I'Fergus McDuck'. Dagus McDuck', 'Molly Mallard A conflict is defined as the same person having at least of entsy in both of the input databases such that either their mother or father for both) listed differently la ench datab. An entry of one for a penon's mother or father should not ce a conflict. In the case of a conflict, the function should return None. For obtained from relational war >>> combise_tree (duck_tren, t'Donald Duck","Scrooge McDuck, "Botasse McDuck"}]} Combining neo-conflicting family tres from different sources can then allow for more information to be >> grandparente('Scrooge Nebuck, combine trees (duck_tre duck trea2) Dingus McDuck'. Molly Mallard in python
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
