AP CSA FRQ Guide
2009 FRQ 3: BatteryCharger
Calculate a continuous battery charge cost using a repeating 24-hour rate table, then find a starting hour that gives the lowest total cost for the required charging time.
Circular Array Costs and Minimum Search22 minute targetarraysmoduloloopsminimum searchhelper methods
Skills Tested
What this FRQ is really practicing
arraysmoduloloopsminimum searchhelper methods
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Part A: add the hourly rates for chargeTime consecutive hours, wrapping around the 24-hour table as often as necessary.
- 2Part B: compare the complete charging cost for each possible starting hour from 0 through 23.
- 3Return an optimal starting hour, rather than the cost; any tied minimum is acceptable.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Failing to wrap around the rate table after midnight.
Choosing the cheapest single hour instead of the cheapest full charge.
Returning the minimum cost instead of its starting hour.
Self Check
Review questions before you submit
Wraps hours through the repeating rate table.
A charge can cross midnight and last longer than a day.
Accumulates rates for the full charging period.
Add one hourly rate for every hour of chargeTime.
Uses getChargingCost when comparing start times.
Reuse part (a) for each candidate hour.
Considers all 24 possible starting hours.
The best start can be any hour from 0 through 23.
Practice Links
