Question 5

OCR Computer Science June 2022 Algorithms and problem solving (H046-02)AS11 marks

On the specification

(a)
2.3 Algorithms
(b)
2.2 Problem solving and programming2.3 Algorithms
(c)
2.2 Problem solving and programming
Question text

5 A veterinary surgery uses a two dimensional array to store bookings for customers to bring in their animal to see the vet. There are ten possible booking slots during each day. An example of the two dimensional array is shown in Fig. 1. • The first column stores the booking slot number, ranging between 1 and 10. • The second column stores the time of the appointment. • The third column stores the customerID of the customer who has booked that slot. 1 9:00 5877RC 2 9:30 9655AS 3 10:00 4 10:30 8754TT 5 11:00 6 11:30 8745SD 7 13:00 9635GH 8 13:30 9 14:00 9874PL 10 14:30 9658SV Fig. 1 If a customerID has been entered for a booking slot then the booking slot has been taken. If no customerID has been entered then the booking slot is available for booking. (a) When customers make an appointment they often ask for the first available booking slot. Describe how a linear search could be used for this purpose. [3] (b) A function findFirst, is used to find the first available appointment. Write the function findFirst that will find the first available appointment and return the booking slot number. If no appointments are available then the function should return "-1". You should write your function using pseudocode or program code. [7] (c) When an available time slot has been found then a valid customerID must be entered to confirm the booking. This is checked by another function called checkCustomerID. This will return true if the customerID is valid or false if the customerID is not valid. State why a function would be used instead of a procedure for this purpose. [1]