AP CSA FRQ Guide
2008 FRQ 1: Trip
Calculate the duration of a trip from its first departure to its final arrival, and find the shortest layover between consecutive flights using the supplied time helper.
ArrayList Traversal and Time Differences22 minute targetArrayListobjectshelper methodsminimum searchedge cases
Skills Tested
What this FRQ is really practicing
ArrayListobjectshelper methodsminimum searchedge cases
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Part A: return the minutes from the first departure to the last arrival, including layovers; return 0 for an empty trip.
- 2Part B: use minutesUntil to compare each flight arrival with the following departure and return the smallest layover.
- 3Return -1 for the shortest layover when there are fewer than two flights.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Adding only flight durations and leaving out layovers.
Reversing the receiver and argument of minutesUntil, producing negative gaps.
Accessing a first pair when the trip has fewer than two flights.
Self Check
Review questions before you submit
Returns 0 for the duration of an empty trip.
Check for no flights before accessing the first or last flight.
Uses flight times and minutesUntil to calculate duration.
The interval starts at the first departure and ends at the last arrival.
Returns -1 when a layover does not exist.
An empty trip or one-flight trip has no layover.
Measures layovers from arrivals to following departures.
Traverse consecutive flight pairs and keep the minimum gap.
Practice Links
