9608_s17_qp_31
A paper of Computer Science, 9608
Questions:
6
Year:
2017
Paper:
3
Variant:
1

Login to start this paper & get access to powerful tools

1
Consider the following user-defined data type: TYPE LibraryBookRecord DECLARE ISBN : INTEGER DECLARE Title : STRING ENDTYPE Write a pseudocode statement to declare a variable, Book, of type LibraryBookRecord. Write a pseudocode statement that assigns ‘Dune’ to the Title of Book. The user-defined data type LibraryBookRecord needs to be modified by adding the following fields: • a field called Genre which can take two values, fiction or non-fiction • a field called NumberOfLoans which can be an integer value in the range 1 to 99 Write the updated version of LibraryBookRecord. A pointer is a variable that stores the address of a variable of a particular type. Consider the code on page 3, which uses the following identifiers: Identifier Data type Description IntPointer ^INTEGER pointer to an integer IntVar INTEGER an integer variable Temp1 INTEGER an integer variable Temp2 INTEGER an integer variable IntVar // assigns the value 57 to the integer // variable IntVar IntPointer @IntVar // assigns to IntPointer the address of the // integer variable IntVar Temp2 IntPointer^ // assigns to variable Temp2 the value at an // address pointed at by IntPointer IntPointer^ Temp1 // assigns the value in the variable Temp1 to // the memory location pointed at by IntPointer The four assignment statements are executed. The diagram shows the memory contents after execution. Variable Memory address Contents . . . IntVar . . . IntPointer . . . Temp1 Temp2 . . . Use the diagram to state the current values of the following expressions: @Temp2 IntPointer IntPointer^ IntPointer^ = Temp2 + 6 Write pseudocode statements that will achieve the following: Assign the value 22 to the variable Temp2. Place the address of Temp1 in IntPointer. Copy the value in Temp2 into the memory location currently pointed at by IntPointer.
2
3
4
A bank has 95 000 customers. Each customer has a unique ID. When a customer uses an Automated Teller Machine (ATM) to obtain cash, their current balance is checked. The balance is stored in a file which has the following fields: • the customer ID (6-digit number in the range 100000 to 999999) • an encrypted PIN • the current balance The file can store a maximum of 100 000 records. Give a reason why a random organisation would be appropriate for this file. An algorithm for inserting a new record in this file uses the following hash function: RecordKey CustomerID MOD 100000 where RecordKey is the record position in the file. Complete the table to show the values generated by the hash function for the given customer IDs. CustomerID RecordKey State the range of possible values for RecordKey. Minimum value of RecordKey: Maximum value of RecordKey: A procedure is written to insert a new record into the file. Complete the algorithm for this procedure. PROCEDURE InsertRecord(CustomerID : INTEGER) RecordKey CustomerID MOD 100000 Success FALSE // Find position for new record and insert it REPEAT IF record at position RecordKey is ……………………… THEN Insert new record at position RecordKey Success TRUE ELSE IF RecordKey = ……………………… THEN RecordKey ……………………… ELSE RecordKey ……………………… + 1 ENDIF ENDIF UNTIL Success = TRUE ENDPROCEDURE Explain why an encrypted version of the PIN is stored in the file. A customer attempts to withdraw cash from an ATM. An algorithm is used to check if the customer has entered the correct PIN. Complete the algorithm. 1. Customer ID is read from card. 2. Customer enters PIN. 3. Customer PIN is 4. 5. Customer record is located in file. 6. 7. If match then transaction can proceed.
5
6
A computer system is used to manage some of the functions in a vehicle. The vehicle has a number of sensors and actuators. One sensor is used to monitor the moisture on the screen. If the moisture exceeds a pre-set value, the windscreen wiper motor turns on automatically. The software used in the computer system is dedicated to the sensor management functions. When the system starts, the software runs some initial tasks. It then loops continuously until the system is switched off. State the name given to the type of system described. Explain your answer to part . Within the software loop, the value of each sensor is read in turn. The value read from the sensor is then processed. State two drawbacks with this method of reading and processing sensor data. Drawback 1 Drawback 2 An alternative method of reading and processing sensor data is to use interrupts. Each sensor is connected so that it can send an interrupt signal to the processor if its value changes. On receipt of an interrupt signal, the processor carries out a number of steps as shown in the following diagram. Interrupt Return to task 1. Disable interrupts 6. Enable interrupts 2. Save current task 3. Identify source of 4. Jump to Interrupt Service Routine interrupt 5. Restore task State the purpose of step 1. State the purpose of step 6. Explain how the current task is saved in step 2. State two benefits of using interrupts to read and process the sensor data. Benefit 1 Benefit 2 The interrupt handler in step 3 has to test each bit of a 16-bit register to discover the source of the interrupt. The contents of the 16-bit register are loaded into the 16-bit accumulator: Accumulator Bit: An instruction is required to achieve the following: • If bit 9 is zero, set the accumulator to zero. • If bit 9 is one, set the accumulator to a non-zero value. Write this instruction using an appropriate bitwise operation.