logo Practice-It logo

rankFamilies

Language/Type: Java Guava collections
Author: Marty Stepp (on 2013/02/19)

You are writing code for a game show called Family Fracas. Write a method named rankFamilies that accepts a Guava Table of strings and strings to integers. The rows represent last names and the columns represent first names; the values are the number of points earned by the person with that first and last name. Your method should return a List of last names, ordered by how many points were earned by the people in that family (the people with that last name). Families that earned more points should appear earlier in the list. For example:

Bobby Jackie Alex Jordan Mary
Smith 30 17 67
Chen 75 14 26
Rivera 32 49 25
Mitchell 18 107 3

According to the table above, Alex Mitchell earned 107 points, Mary Rivera earned 25 points, etc. The Smith family earned 114 points, the Chens earned 115 points, the Riveras earned 106 points, and the Mitchells earned 128 points, so your method will return the list [Mitchell, Chen, Smith, Rivera]. You may assume that the table and its elements are not null and that no two families will earn exactly the same number of points. Your method must run in O(N log N) time or better, where N is the number of people in the table.

Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.