Page 572 - AP Computer Science A, 7th edition
P. 572
updated such that
∗ column number matches contestant’s position in arr.
∗ @param arr the array to be sorted
∗/
private void sort(Contestant[] arr) { /∗ implementation not shown ∗/ }
/∗∗ Sorts each row of contestants into increasing order by score.
∗ Postcondition: Contestant with highest score in row[k] is
/∗∗ Returns name of contestant with highest score.
∗ Precondition:
∗ – Contestants have not been sorted by score.
∗ – Top score is unique.
∗ – Only one contestant has the highest score.
∗ @return name of contestant with highest score ∗/
public String findWinnerName()
{ /∗ to be implemented in part(c) ∗/ }
}
(b) Write the ContestOrganizer method sortAllRows. This method should sort the contestants by score in each row, from lowest to highest. Example: Suppose contestants are as shown below:
∗ 0<=k<NUM_ROWS.
in the rightmost column of row[k], public void sortAllRows()
∗/
{ /∗ to be implemented in part(b) ∗/ }