A tennis tournament has 342 players. A single match involves 2 players. The winner of a match will play the winner of a match in the next round, whereas losers are eliminated from the tournament. The 2 players who have won all previous rounds play in the final game, and the winner wins the tournament. Here are two approaches to designing an algorithm to calculate the total number of matches needed to determine the winner.
a) Compute 342/2=171 to get the number of pairs (matches) in the first round, which results in 171 winners to go on to the second round. Compute 171/2=85 with 1 left over, which results in 85 matches in the second round and 85 winners, plus the 1 left over, to go on the third round. For the third round, compute 86/2=43, so the third round has 43 matches, and so on.
The total number of matches is 171+85+43+... Finish this process in order to find the total number of matches.
b) Here is another approach. Realize that each match results in exactly one loser, so there must be the same number of matches as losers in the tournament. How many losers are in the tournament?
Without actually writing the two algorithms, give your opinion of their relative clarity, elegance, and efficiency