2023 AP Computer Science A FRQ

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • Write the makeAppointment method, which searches the periods from startPeriod to endPeriod, inclusive, for the earliest block of duration available minutes in the lowest-numbered period. If such a block is found, the makeAppointment method calls the helper method reserveBlock to mark the minutes in the block as unavailable and returns true. If no such block is found, the makeAppointment method returns false.
    Consider the following list of unavailable and available minutes in periods 2, 3, and 4 and three successive calls to makeAppointment.
    The method call makeAppointment(2, 4, 22) returns true and results in the minutes 5 through 26, inclusive, in period 4 being marked as unavailable.
    The method call makeAppointment(3, 4, 3) returns true and results in the minutes 0 through 2, inclusive, in period 3 being marked as unavailable.
    The method call makeAppointment(2, 4, 30) returns false, since there is no block of 30 available minutes in periods 2, 3, or 4.
    The following shows the updated list of unavailable and available minutes in periods 2, 3, and 4 after the three example method calls are complete.
    Complete method makeAppointment. Assume that findFreeBlock works as intended, regardless of what you wrote in part (a). You must use findFreeBlock and reserveBlock appropriately in order to receive full credit.
    Intro: 00:00
    Pseudocode: 01:13
    Writing the code: 02:50
    Testing the first method call: 06:48
    Testing the second method call: 10:18
    Testing the third method call: 11:40
    Solution: 14:49

Комментарии •