You will write the three parts of a program that builds a tree from a table of differences, the UPGMA method of the lesson.
The idea. Join the closest pair of groups. The new group is at half their distance. Its distance to every other group is the average of the two old distances, weighted by the size of the groups. Repeat until one group is left.
Your tasks.
closest. It gives the pair of groups with the smallest difference.average_distance. It gives the distance from a new group to another group.build_tree. It gives the list of joins as (group, group, height).Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…