Question
The version of the teamStandings method shown in Figure 14.25 may do a bit more work than necessary. The for loop in this method looks
The version of the teamStandings method shown in Figure 14.25 may do a bit more work than necessary. The for loop in this method looks at every single entry in the racer array. Typically,
there will be many racers who finish after the slowest racer who scores. That is, once the loop has found enough racers from each of the teams to compute a score for every team, it can stop without looking at the remaining entries in the array.
Show how to modify our definition of teamStandings to take advantage of this observation. Your new version of this method should expect an int parameter, teamCount, which will tell it how many teams were actually competing in the meet. You will have to change the first loop so that it keeps track of how many team scores have been determined and stops when this number equals teamCount.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started