Loading....
|
Press & Hold to Drag Around |
|||
|
Click Here to Close |
|||
Question 1 Report
A wildlife rescue centre records the mass of each hedgehog before release. The technician uses a program with a variable called totalMass. For each animal, the program adds the new mass to this total and increases numberReleased by one. At the end, a subroutine calculates the mean mass. The technician wants the program to be structured so that the calculation can also be used for badgers in a separate test program.
(a) Explain why totalMass should be initialised to 0 before the loop starts. [2]
(b) When the mean-mass subroutine is called, state one input parameter it needs. [1]
(a) totalMass is an accumulator, so it needs the known starting value 0 before masses are added. [1] This prevents an old or undefined value from being included in the final total. [1]
(b) The mean-mass subroutine needs totalMass as an input parameter; it may also need numberReleased to calculate the mean. [1]
(a) totalMass is an accumulator, so it needs the known starting value 0 before masses are added. [1] This prevents an old or undefined value from being included in the final total. [1]
(b) The mean-mass subroutine needs totalMass as an input parameter; it may also need numberReleased to calculate the mean. [1]
Question 2 Report
The wildlife camera program stores an image filename, date and reserve zone after each photograph is taken. A ranger runs a command that reads the log file and displays only records from zone C. The ranger may enter a lower-case c even though the file uses an upper-case C. The program is being tested before the cameras are installed in remote woodland.
(a) State one test datum for the zone input that would test case handling. [1]
(b) Explain how converting the entered zone to upper case can improve the search. [2]
Fig. 1 shows a recycling kiosk at a community centre. A user scans a barcode, and the program displays the material type and sends a message to the correct bin mechanism. At closing time, a subroutine writes the number of items of each type to a text file. The operator needs a clear output if the barcode cannot be found in the lookup file.
(a) State the input device used to enter the barcode. [1]
(b) Explain why the lookup file is read rather than opened for writing during normal use. [2]
(c) When no matching code is found, state one suitable output. [1]
Wildlife-camera program
c. [1]c to C, matching the format used in stored records. This means a valid record is not missed solely because of letter case. [2]Recycling kiosk
Barcode not found. A sound or indicator light is also acceptable. [1]Wildlife-camera program
c. [1]c to C, matching the format used in stored records. This means a valid record is not missed solely because of letter case. [2]Recycling kiosk
Barcode not found. A sound or indicator light is also acceptable. [1]Question 3 Report
A wildlife camera program sends a new message to researchers when movement is detected at night but the camera is not in maintenance mode. The sensor subroutine gives movement, the clock subroutine gives night, and an engineer sets maintenance. The program uses sendMessage = movement AND night AND NOT maintenance. During field testing, an animal moves during the day. In another test, movement occurs at night while maintenance is enabled. Researchers need to understand why neither event should send a message.
(a) Explain why maintenance mode is negated in the statement. [2]
(b) When movement is True, night is False and maintenance is False, state the value of sendMessage. [1]
(c) When movement is True, night is True and maintenance is True, state the value of sendMessage. [1]
(d) Explain why AND is suitable for the three checks. [1]
Fig. 1 shows part of the access-control program used at a community workshop. A member may use the laser cutter only if their card is valid and they have completed safety training. The two input values are stored as Boolean variables. The main program displays a message telling the member whether access is allowed. The programmer wants the condition to be clear so that a technician can test it using all possible input combinations.
(a) Explain when accessAllowed is True. [2]
(b) When cardValid is False and trained is True, state the value displayed for accessAllowed. [1]
Wildlife-camera condition
maintenance must be False, represented by NOT maintenance being True. [1]sendMessage is False. [1]NOT True is True AND True AND False, so sendMessage is False. [1]AND is suitable because all three required conditions must be satisfied: movement, night-time, and no maintenance mode. [1]Workshop access condition
accessAllowed is True only when the card is valid [1] and safety training is complete, so trained is True. [1]accessAllowed displays False. [1]Wildlife-camera condition
maintenance must be False, represented by NOT maintenance being True. [1]sendMessage is False. [1]NOT True is True AND True AND False, so sendMessage is False. [1]AND is suitable because all three required conditions must be satisfied: movement, night-time, and no maintenance mode. [1]Workshop access condition
accessAllowed is True only when the card is valid [1] and safety training is complete, so trained is True. [1]accessAllowed displays False. [1]Question 4 Report
The canteen ordering program stores each order in a queue before it is sent to the kitchen. During a busy lunch break, a network connection fails after the customer has paid but before the displayed confirmation appears. The customer presses the Pay button again. The programmer must make the program robust so that it does not create duplicate orders or lose a paid order. A transaction log is available, and each payment provider message includes a unique payment reference.
(a) Explain why the payment reference should be checked before a new order is added. [2]
(b) When the network fails, describe one message that should be displayed to the customer. [1]
(c) Explain one use of a transaction log during recovery. [2]
(d) When the program receives the same payment reference twice, state what it should do. [1]
(a) Check whether the unique payment reference has already been processed before adding an order. This prevents a second request from creating a duplicate order or causing a duplicate charge. [2]
(b) A suitable message is: Payment is being checked. Do not submit again. [1]
(c) A transaction log records the stage or status of each order. During recovery, the program can use it to identify a paid order that was not completed and recover it rather than losing it or creating it twice. [2]
(d) If the same payment reference arrives twice, do not create another order. Ignore or flag the duplicate request. [1]
(a) Check whether the unique payment reference has already been processed before adding an order. This prevents a second request from creating a duplicate order or causing a duplicate charge. [2]
(b) A suitable message is: Payment is being checked. Do not submit again. [1]
(c) A transaction log records the stage or status of each order. During recovery, the program can use it to identify a paid order that was not completed and recover it rather than losing it or creating it twice. [2]
(d) If the same payment reference arrives twice, do not create another order. Ignore or flag the duplicate request. [1]
Question 5 Report
A city archive converts paper maps into digital records. Each record has a map ID, district name, scan date and file pointer. The records are stored in a binary search tree using map ID as the key. An archivist enters IDs in the order 60, 40, 85, 30, 50 and 75. The program must search for ID 75 and then delete ID 30 after a duplicate scan is discovered. The archive manager needs the tree to remain valid after the delete command.
(a) Explain the route used to find ID 75. [2]
(b) When deleting ID 30, explain why this is simpler than deleting ID 40. [2]
(c) Explain one benefit of using a record rather than storing only map IDs in the tree. [2]
(a) Begin at 60. Since 75 is greater than 60, follow the right branch. Then compare 75 with 85; since 75 is less than 85, follow the left branch to 75. [2]
(b) ID 30 is a leaf node, so it has no children. Its parent's pointer can simply be changed to NULL. ID 40 has children, so deleting it would require reconnecting or replacing nodes to preserve the binary-search-tree structure. [2]
(c) A record keeps the district, scan date and file pointer associated with its map ID. Once the node is located, the program can retrieve all relevant map details rather than only the ID. [2]
(a) Begin at 60. Since 75 is greater than 60, follow the right branch. Then compare 75 with 85; since 75 is less than 85, follow the left branch to 75. [2]
(b) ID 30 is a leaf node, so it has no children. Its parent's pointer can simply be changed to NULL. ID 40 has children, so deleting it would require reconnecting or replacing nodes to preserve the binary-search-tree structure. [2]
(c) A record keeps the district, scan date and file pointer associated with its map ID. Once the node is located, the program can retrieve all relevant map details rather than only the ID. [2]
Question 6 Report
Fig. 1 shows a section of a game program that validates a move on a 10 by 10 board. The player enters a row number into row. The program should reject row numbers outside 1 to 10. A message is displayed when the entered row is invalid.
(a) Explain why the relational tests are joined with OR. [1]
(b) When row is 0, state the path followed. [1]
(c) When row is 10, state the path followed. [1]
(d) When row is 14, explain which relational test is true. [1]
(e) When the board is changed to 12 rows, write the amended invalid-row condition. [1]
The canteen's allergy checker compares a selected meal code with a restricted code held in restrictedMeal. The code chosen by a student is stored in mealCode. If the two values are equal, the program must display a message and call a subroutine that suggests an alternative meal.
(a) Explain the Boolean result when mealCode = "P17" and restrictedMeal = "P17". [1]
(b) When the codes are "P17" and "V04", state the result of mealCode = restrictedMeal. [1]
(c) When the codes are equal, write two commands that could form the THEN block. [2]
Game-board validation
OR is used because a row is invalid if it is below the minimum of 1 or above the maximum of 10. It cannot be both at once. [1]row is 0, row < 1 is true. The flowchart follows the true path to Invalid move. [1]row is 10, neither row < 1 nor row > 10 is true. It follows the false path to Make move. [1]row is 14, the true relational test is row > 10. [1]row < 1 OR row > 12 [1]Allergy checker
"P17", they are equal, so mealCode = restrictedMeal is true. [1]"P17" and "V04", they differ, so the equality test is false. [1]THEN block is:DISPLAY "Restricted meal selected"
CALL suggestAlternative()Game-board validation
OR is used because a row is invalid if it is below the minimum of 1 or above the maximum of 10. It cannot be both at once. [1]row is 0, row < 1 is true. The flowchart follows the true path to Invalid move. [1]row is 10, neither row < 1 nor row > 10 is true. It follows the false path to Make move. [1]row is 14, the true relational test is row > 10. [1]row < 1 OR row > 12 [1]Allergy checker
"P17", they are equal, so mealCode = restrictedMeal is true. [1]"P17" and "V04", they differ, so the equality test is false. [1]THEN block is:DISPLAY "Restricted meal selected"
CALL suggestAlternative()Question 7 Report
In the planetarium quiz, a player earns a score based on the number of correct answers. The function awardStars(correct) should return 3 stars for 10 correct, 2 stars for 7 to 9 correct, 1 star for 4 to 6 correct, and 0 otherwise. The main program adds the returned stars to a displayed total. The programmer wants to test boundary values before the new quiz is released to visiting schools.
(a) Explain why 6, 7, 9 and 10 are useful test data for this function. [2]
(b) When awardStars(6) is called, state the value returned. [1]
(c) Explain why a test using 11 correct answers is also needed. [1]
(a) The values 6, 7, 9 and 10 lie at the limits of the score ranges. They test transitions between selection branches and can reveal an incorrect comparison operator or range boundary. [2]
(b) awardStars(6) returns 1, because 6 is within the range from 4 to 6 inclusive. [1]
(c) A test with 11 correct answers checks invalid or extreme input above the maximum possible score. [1]
(a) The values 6, 7, 9 and 10 lie at the limits of the score ranges. They test transitions between selection branches and can reveal an incorrect comparison operator or range boundary. [2]
(b) awardStars(6) returns 1, because 6 is within the range from 4 to 6 inclusive. [1]
(c) A test with 11 correct answers checks invalid or extreme input above the maximum possible score. [1]
Question 8 Report
Fig. 1 shows an adjacency list for walking routes between cabins at an outdoor activity centre. Each list begins with a cabin and contains the cabins directly joined by a marked path. The route-planning program uses this graph structure because not every cabin is connected to every other cabin. A new path is planned from Cedar to Lake, so the manager needs to update the stored data before the map is displayed to visitors.
(a) Explain what the entry Lake in Pine's list means. [1]
(b) When a two-way path between Cedar and Lake opens, explain the updates required. [2]
The diagram shows a stack of undo commands in a tablet drawing program. The player has drawn several shapes, and the program stores each completed command so that the most recent action can be reversed. The top pointer is used by the undo subroutine. The designer chooses a stack rather than a queue because the order of removal must match the way users expect an undo button to work.
(a) Explain the command returned by one undo operation. [1]
(b) When the player chooses Redo after undoing a command, explain why the program may need a second stack. [2]
Adjacency list
(a) Lake appearing in Pine's list means there is a direct path, or edge, between Pine and Lake. [1]
(b) Because the new path is two-way, add Lake to Cedar's adjacency list and add Cedar to Lake's adjacency list. Both directions must be stored. [2]
Undo stack
(a) The top of the stack is the most recent command, so one undo operation returns add label. A stack removes items last in, first out. [1]
(b) An undone command must be retained rather than discarded if Redo is possible. It can be pushed onto a second, redo stack, then popped from that stack and applied again when the player chooses Redo. [2]
Adjacency list
(a) Lake appearing in Pine's list means there is a direct path, or edge, between Pine and Lake. [1]
(b) Because the new path is two-way, add Lake to Cedar's adjacency list and add Cedar to Lake's adjacency list. Both directions must be stored. [2]
Undo stack
(a) The top of the stack is the most recent command, so one undo operation returns add label. A stack removes items last in, first out. [1]
(b) An undone command must be retained rather than discarded if Redo is possible. It can be pushed onto a second, redo stack, then popped from that stack and applied again when the player chooses Redo. [2]
Question 9 Report
The national park booking service stores campsite availability in a hash table with 101 buckets. A booking record contains a reservation code, arrival date, number of nights and payment status. The hash function is based on the numeric part of the reservation code. During a holiday period, many codes map to the same bucket and the response time of the search command has become variable. The programmer is considering separate chaining, open addressing and resizing the table. The service must keep all confirmed bookings and must not lose a record if two codes have the same hash value.
(a) Explain what is meant by a collision in this hash table. [2]
(b) When separate chaining is used, explain how a search for one reservation code is carried out. [3]
(c) Explain two effects of a high load factor on this system. [3]
(d) When the table is resized, explain why every existing record normally has to be processed again. [2]
(e) Explain one reason that a booking record should include payment status as a field rather than using a separate unrelated list. [2]
(a) A collision occurs when two different reservation codes produce the same hash-table index. Both records must then be stored without one overwriting the other. [2]
(b) To search using separate chaining:
[3]
(c) A high load factor means there are many records relative to the number of buckets. This causes more collisions and makes chains or probing sequences longer. Consequently, searches and insertions take longer or have less predictable response times. [3]
(d) Resizing changes the table size. Each existing key must be hashed again because its resulting index may change in the new table. [2]
(e) Including payment status in the booking record keeps it associated with the correct reservation. The whole booking can be retrieved and updated together, reducing the risk of mismatches with a separate unrelated list. [2]
(a) A collision occurs when two different reservation codes produce the same hash-table index. Both records must then be stored without one overwriting the other. [2]
(b) To search using separate chaining:
[3]
(c) A high load factor means there are many records relative to the number of buckets. This causes more collisions and makes chains or probing sequences longer. Consequently, searches and insertions take longer or have less predictable response times. [3]
(d) Resizing changes the table size. Each existing key must be hashed again because its resulting index may change in the new table. [2]
(e) Including payment status in the booking record keeps it associated with the correct reservation. The whole booking can be retrieved and updated together, reducing the risk of mismatches with a separate unrelated list. [2]
Question 10 Report
In the recycling-centre program, a conveyor starts only when the emergency stop is not pressed and the safety gate is closed. The controller receives signals from two switches. The Boolean variable stopPressed is True when the emergency button is pressed. gateClosed is True when the gate is fully shut. A technician is writing test cases for the main program and needs to include conditions that would stop the conveyor. The program must fail safely if either protective requirement is not met.
(a) Explain why the required condition can be written as NOT stopPressed AND gateClosed. [2]
(b) When stopPressed is False and gateClosed is True, state whether the conveyor may start. [1]
(c) When stopPressed is True and gateClosed is True, state whether the conveyor may start. [1]
The city bike-hire app offers a free ride extension if a rider has reported a faulty docking station or if the system has recorded a payment error. A customer service subroutine sets faultReport and paymentError. The following statement is used: extendRide = faultReport OR paymentError. A rider has made a fault report but no payment error is recorded. Another rider has neither condition recorded. Customer service needs to explain the two different displayed outcomes without changing the database records.
(a) Explain why the first rider receives an extension. [2]
(b) When both Boolean variables are False, state the value of extendRide. [1]
(c) Explain why changing OR to AND would reduce the number of riders who receive an extension. [1]
Recycling-centre conveyor condition
NOT stopPressed requires the emergency stop button not to be pressed. [1] AND gateClosed requires the gate to be closed too, because both protective conditions are required before the conveyor starts. [1]stopPressed is False, then NOT stopPressed is True. True AND True means the conveyor may start. [1]stopPressed is True, then NOT stopPressed is False. False AND True is False, so the conveyor may not start. [1]Bike-hire extension condition
faultReport=True. [1] Because OR is True when one input is True, extendRide is True and the rider receives an extension. [1]extendRide is False. [1]AND would require both a fault report and a payment error. [1] Fewer riders would meet both conditions, so fewer would receive an extension.Recycling-centre conveyor condition
NOT stopPressed requires the emergency stop button not to be pressed. [1] AND gateClosed requires the gate to be closed too, because both protective conditions are required before the conveyor starts. [1]stopPressed is False, then NOT stopPressed is True. True AND True means the conveyor may start. [1]stopPressed is True, then NOT stopPressed is False. False AND True is False, so the conveyor may not start. [1]Bike-hire extension condition
faultReport=True. [1] Because OR is True when one input is True, extendRide is True and the rider receives an extension. [1]extendRide is False. [1]AND would require both a fault report and a payment error. [1] Fewer riders would meet both conditions, so fewer would receive an extension.Question 11 Report
A sports physiotherapy clinic uses a program to make file names for exercise videos. A therapist enters a patient reference and an exercise title. Spaces in the title must be replaced with underscore characters so that the file can be uploaded to the clinic server. The original title is still displayed to patients in a friendly form.
(a) Explain why the program should keep a separate original title for the patient display. [1]
(b) When the title is ankle balance, state the server-safe title after spaces are replaced. [1]
(c) Explain how a replace operation is preferable to manually selecting every space when titles have different lengths. [1]
For each volunteer on a river-cleanup day, the registration program creates a badge message from a first name and a team colour. The organiser wants the message displayed as WELCOME, NAME - TEAM TEAM. Names are entered with normal capitalisation, while team colours are stored in lower case. The program should not alter the volunteer's original name because it is also printed on a certificate.
(a) Explain why the team colour can be converted to upper case without changing the stored name. [1]
(b) When the name is Asha and the colour is green, state the complete badge message. [1]
(c) Explain how concatenation includes punctuation and spaces in the final string. [1]
Exercise-video titles
ankle balance gives ankle_balance. [1]Volunteer badge messages
WELCOME, Asha - GREEN TEAM. [1]Exercise-video titles
ankle balance gives ankle_balance. [1]Volunteer badge messages
WELCOME, Asha - GREEN TEAM. [1]
Would you like to proceed with this action?