Trace minibus seat bookings

Scenario. A campus minibus has 12 seats. Groups request 5, 9, and 7 seats in that order. A request is accepted only when the whole group fits in the seats that remain.

Inputs. Seat Capacity = 12 and Group Requests = [5, 9, 7]. All values are positive whole numbers.

Rules and notation. Booked Seats is the number of seats already assigned. Accepted Group Count is the number of accepted requests. A rejected request does not change either value.

Assumptions. A group cannot be split or moved ahead of another group. A rejected request receives no seats.

Before tracing, state the expected decisions, final booked seats, and accepted group count from the scenario. Then trace Listing 1 one request at a time and record both state values after every decision.

Listing 1: Minibus seat-booking algorithm for a 12-seat capacity that records each group decision, the final number of booked seats, and the accepted group count.
Input: Seat Capacity, Group Requests
Output: Decisions, Final Booked Seats, Accepted Group Count
Start
   Set Booked Seats to 0
   Set Accepted Group Count to 0
   Set Decisions to an empty collection

   For each Seats Requested in Group Requests
      If Booked Seats + Seats Requested <= Seat Capacity
         Set Booked Seats to Booked Seats + Seats Requested
         Set Accepted Group Count to Accepted Group Count + 1
         Set Decision to "Accept"
      Else
         Set Decision to "Reject"
      End If
      Add Decision to Decisions
   End For

   Output Decisions, Booked Seats, Accepted Group Count
End

Table 1 supplies the first row. Complete the remaining rows before opening the solution.

Table 1: Partly completed minibus trace for a 12-seat capacity and group requests of 5, 9, and 7 seats. The first row models how to record the condition, decision, and two state values before and after one iteration.
Step Seats requested Booked before Count before Evaluated condition Decision Booked after Count after
1 5 0 0 0 + 5 <= 12 is true Accept 5 1
2 9 5 1
3 7

Deliverable. State the expected outputs before tracing, complete the trace table, record the observed outputs, and give a verdict.

Success criteria. The trace follows the supplied order, preserves both state values after rejection, never shows more than 12 booked seats, and compares the expected and observed results.

For the second request, evaluate 5 + 9 <= 12. A rejected request does not replace the current number of booked seats.