AP CSA FRQ Guide

2023 FRQ 1: AppointmentBook

Write two methods for scheduling appointments. The first finds the earliest free block of consecutive minutes in one class period. The second searches a range of periods, reserves the first valid block, and reports whether the appointment was made.

Methods and Search22 minute targetmethodsloopssearchhelper methodsinclusive bounds

Skills Tested

What this FRQ is really practicing

methodsloopssearchhelper methodsinclusive bounds

Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.

Starter Approach

How to begin without copying a solution

  1. 1Part A: search minutes 0 through 59 for the first block of duration consecutive free minutes.
  2. 2Use isMinuteFree(period, minute) to test availability and return the starting minute of the earliest valid block.
  3. 3Return -1 if no block of the requested duration exists in that period.
  4. 4Part B: search periods from startPeriod through endPeriod inclusive, reserve the first available block, and return true; return false if no block exists.

Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.

Common Mistakes

Mistakes to watch for while writing

Returning the ending minute of a free block instead of the starting minute.
Checking only whether one minute is free instead of verifying duration consecutive minutes.
Forgetting to reset the consecutive counter when a minute is unavailable.
Looping with period < endPeriod and missing the last requested period.
Finding a block but forgetting to call reserveBlock before returning true.

Self Check

Review questions before you submit

Defines findFreeBlock with int return type and period/duration parameters.

Part A must return the starting minute or -1.

Checks minutes across the 60-minute period.

Loop through possible minutes from 0 up to 59.

Uses isMinuteFree to test availability.

The helper method must be called with the period and minute.

Tracks consecutive free minutes.

Use a counter, nested check, or equivalent logic to verify the whole duration.

Returns the first minute of a valid free block.

If using a running count, the start is usually minute - duration + 1.

Returns -1 when no block is found.

The failure return should happen after the search is complete.

Defines makeAppointment with boolean return type and three int parameters.

Part B returns whether the appointment was successfully scheduled.

Searches periods from startPeriod through endPeriod inclusive.

Use <= endPeriod so the last requested period is checked.

Practice Links

Where to go next