2025 AP Computer Science A FRQ #3B

Write the Round method buildMatches. This method should return a new ArrayList{Match} object by pairing competitors from competitorList according to the following rules. • If the number of competitors in competitorList is even, the best-ranked competitor is paired with the worst-ranked competitor, the second-best-ranked competitor is paired with the second-worst-ranked competitor, etc. • If the number of competitors in competitorList is odd, the competitor with the best rank is ignored and the remaining competitors are paired according to the rule for an even number of competitors. Each pair of competitors is used to create a Match object that should be added to the ArrayList to return. Competitors may appear in either order in a Match object, and matches may appear in any order in the returned ArrayList. The following example shows the contents of competitorList in a Round object r1 containing an odd number of competitors and the ArrayList of Match objects that should be returned by the call r1.buildMatches(). Complete the buildMatches method. Intro: 00:00 Writing the pseudocode: 01:02 Writing the code: 04:42 Testing the code with odd example: 14:34 Testing the code with even example: 16:58 Final solution: 19:57