Cambridge IGCSE · thinka-original Practice Paper
2024 Cambridge IGCSE Computer Science (0478) Practice Paper with Answers
Thinka Jun 2024 (V1) Cambridge IGCSE-Style Mock — Computer Science (0478)
Paper 11: Computer Systems Theory
Show answer & marking schemeHide answer & marking scheme
Worked solution
Marking scheme
Show answer & marking schemeHide answer & marking scheme
Worked solution
Marking scheme
Show answer & marking schemeHide answer & marking scheme
Worked solution
Marking scheme
Describe how the TLS protocol is used to establish a secure session and transmit data between the browser and the web server.
Show answer & marking schemeHide answer & marking scheme
Worked solution
2. The web server responds by sending its digital certificate, which contains the server's public key.
3. The web browser validates the digital certificate against a built-in list of trusted Certificate Authorities (CAs) to verify the server's identity.
4. Once validated, the web browser generates a temporary, symmetric session key (used for fast encryption during the session).
5. The browser encrypts this session key using the server's public key and transmits it back to the web server.
6. The web server decrypts the message using its matching private key to obtain the symmetric session key.
7. For the remainder of the session, both the web browser and web server encrypt and decrypt all transmitted data using this shared symmetric session key.
Marking scheme
- Browser requests secure connection (sends client hello)
- Server sends its digital certificate
- Digital certificate contains the server's public key
- Browser verifies/validates the digital certificate with a Certificate Authority (CA)
- Browser generates a symmetric/session key
- Browser encrypts the session key using the server's public key
- Server decrypts the session key using its private key
- Symmetric encryption is used for subsequent communication/data transmission
The dome must maintain a constant temperature between 24 °C and 28 °C. If the temperature exceeds 28 °C, ventilation fans are turned on. If the temperature drops below 24 °C, a heater is turned on.
Explain how the automated system uses sensors, a microprocessor, and actuators to control the climate in the dome.
Show answer & marking schemeHide answer & marking scheme
Worked solution
2. The raw analogue readings from the temperature sensor are converted to digital data using an Analogue-to-Digital Converter (ADC) so they can be processed by the computer system.
3. The microprocessor receives the digital values and compares them with the pre-programmed range values of 24 °C and 28 °C.
4. If the comparison shows that the temperature has exceeded 28 °C, the microprocessor sends a digital signal to the actuator responsible for the ventilation fans to turn them on.
5. If the comparison shows that the temperature has dropped below 24 °C, the microprocessor sends a digital signal to the actuator responsible for the heater to turn it on.
6. If the temperature is between 24 °C and 28 °C, the microprocessor sends signals to turn off both devices (or keep them off).
7. The digital control signals from the microprocessor are converted back to analogue signals using a Digital-to-Analogue Converter (DAC) to drive the physical actuators.
8. This loop repeats continuously to maintain the desired environment.
Marking scheme
- Temperature sensor continuously takes readings / measures temperature
- Analogue values are converted to digital using an ADC
- Microprocessor compares temperature to pre-set parameters / range (24 °C to 28 °C)
- If temperature > 28 °C, microprocessor sends signal to actuator to turn on ventilation fans
- If temperature < 24 °C, microprocessor sends signal to actuator to turn on the heater
- Actuators are used to control physical devices (fans/heaters)
- Digital control signals are converted to analogue using a DAC (to drive actuators)
- Process is continuous / repeats in an infinite loop
Describe how a checksum is generated, transmitted, and used to verify the integrity of the data.
Show answer & marking schemeHide answer & marking scheme
Worked solution
2. The sending device applies a specific mathematical algorithm to the data block to calculate a checksum value (e.g., adding the binary values of all bytes in the block).
3. This calculated checksum value is appended to the block of data before transmission.
4. The combined block of data and the checksum are transmitted across the network to the receiving computer.
5. Upon receiving the transmission, the receiver extracts the data block and the original checksum.
6. The receiver applies the exact same mathematical algorithm to the received data block to generate its own recalculated checksum value.
7. The receiver compares its newly calculated checksum value against the checksum value sent by the sender.
8. If both checksum values are identical, the data has been transmitted successfully without corruption.
9. If the values do not match, an error has occurred during transmission, and the receiver requests a retransmission of that block of data.
Marking scheme
- Data is grouped into blocks before transmission
- Sending device applies a mathematical algorithm to the data block to calculate a checksum
- Checksum is appended to/sent along with the data
- Receiving device receives both the data block and the checksum
- Receiving device applies the same algorithm to the received data block
- Receiving device recalculates its own checksum
- Both checksum values are compared
- If they match, the data is correct / free of errors
- If they do not match, an error has occurred (and retransmission is requested)
1 1 0 1 1 0 0 1 0 1 0 1
The following operations are performed in sequence:
1. A logical right shift of 2 places is performed on the contents of the register.
2. A logical left shift of 3 places is performed on the result of the first shift.
Complete the trace table to show the 12-bit binary values in the register after each operation.
OperationRegister Bits11109876543210Initial contents110110010101After logical right shift of 2 places After logical left shift of 3 places
Show answer & marking schemeHide answer & marking scheme
Worked solution
- In a logical right shift, all bits move to the right by 2 positions.
- The rightmost 2 bits (01) are discarded.
- The vacant positions on the left (bits 11 and 10) are filled with 0s.
- This yields: 0 0 1 1 0 1 1 0 0 1 0 1
Step 2: Perform a logical left shift of 3 places on the result from Step 1 (001101100101).
- In a logical left shift, all bits move to the left by 3 positions.
- The leftmost 3 bits (001) are discarded.
- The vacant positions on the right (bits 2, 1, and 0) are filled with 0s.
- This yields: 1 0 1 1 0 0 1 0 1 0 0 0
Marking scheme
- 1 mark for correct shifting of the bits (1101100101 shifts to bits 9 down to 0)
- 1 mark for correct padding of two 0s at the left (bits 11 and 10)
After logical left shift of 3 places:
- 1 mark for correct shifting of the previous row's bits (101100101 shifts to bits 11 down to 3)
- 1 mark for correct padding of three 0s at the right (bits 2 down to 0)
**(a)** The system has a wind-speed sensor with a hexadecimal identifier of **3D**.
**(i)** Convert the hexadecimal value **3D** into an 8-bit binary number. [3]
**(ii)** Convert the hexadecimal value **3D** into a denary number. Show all your working. [3]
**(b)** Explain why the developers of the buoy's software choose to use hexadecimal rather than binary to represent memory addresses and raw sensor values when debugging. [3]
**(c)** The buoy measures water temperature in degrees Celsius (°C) and represents values as 8-bit signed integers using two's complement.
**(i)** Convert the two's complement binary byte **11101011** to its denary value. Show all your working. [4]
**(ii)** Convert the denary value **-44** to an 8-bit two's complement binary number. Show all your working. [4]
**(d)** **(i)** A sensor reading represented as the byte **10110000** is shifted three places to the right using a logical right shift.
State the resulting 8-bit binary number and explain the mathematical effect of this shift on the original integer value. [4]
**(ii)** Another sensor reading holds the byte **11001100**. Explain the consequence of performing a logical left shift of two places on this byte. [3]
**(e)** The buoy transmits warning messages using text characters.
**(i)** Identify two differences between the ASCII character set and the Unicode character set. [4]
**(ii)** A portion of an ASCII lookup table is shown below:
| Character | Decimal ASCII Value |
|---|---|
| A | 65 |
| B | 66 |
| C | 67 |
| D | 68 |
| E | 69 |
The word **CAB** is transmitted. Convert each character of this word into its corresponding 8-bit binary ASCII byte. Show your working by calculating the binary values. [6]
Show answer & marking schemeHide answer & marking scheme
Worked solution
**(a)**
**(i)** Split 3D into two hexadecimal digits: 3 and D.
- 3 in 4-bit binary = 0011
- D (which represents 13 in denary) in 4-bit binary = 1101
Combine them: **00111101**
**(ii)** Multiply the place values of the digits:
- Place values are \(16^1\) and \(16^0\) (or 16 and 1).
- \(3 \times 16 = 48\)
- \(D \times 1 = 13 \times 1 = 13\)
- Sum: \(48 + 13 = 61\)
**(b)**
- Hexadecimal numbers are much shorter and more concise to write/read than binary representations.
- They are less prone to human errors such as transcription/input errors when debugging codes.
- Each hexadecimal character represents exactly 4 binary bits (one nibble), making the conversion straightforward.
**(c)**
**(i)** For 8-bit two's complement, the place values are:
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
Binary string: 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1
- MSB weight: \(-128 \times 1 = -128\)
- Other active weights: \(64 + 32 + 8 + 2 + 1 = 107\)
- Sum: \(-128 + 107 = -21\)
**(ii)** To convert -44 to two's complement:
1. Convert positive 44 to 8-bit binary first: \(32 + 8 + 4 = 44\) -> **00101100**
2. Invert all bits (one's complement): **11010011**
3. Add 1: **11010100**
**(d)**
**(i)** Shifting **10110000** logically right by three places:
- Pad three 0s on the left: **00010110** (the original rightmost bits '000' are discarded).
- Mathematical effect: A logical right shift of 3 places divides the integer value by \(2^3\) (which is 8). Precision is lost as any fractional part is discarded.
**(ii)** Shifting **11001100** logically left by two places:
- The two leftmost bits are '11'. Shifting left by 2 places pushes these '1' bits off the left edge of the byte.
- This causes an **overflow error**.
- Consequently, the mathematical result is incorrect (it should multiply by 4, but instead the value wraps/is corrupted because the most significant bits are lost).
**(e)**
**(i)**
- **Bit depth:** ASCII uses 7 or 8 bits to represent characters, whereas Unicode uses 16 or 32 bits per character.
- **Character limit:** ASCII can only represent up to 128 (standard) or 256 (extended) different characters, whereas Unicode can represent over 100,000 unique characters, supporting multiple languages and global alphabets.
**(ii)**
- **C** = 67 -> \(64 + 2 + 1\) -> **01000011**
- **A** = 65 -> \(64 + 1\) -> **01000001**
- **B** = 66 -> \(64 + 2\) -> **01000010**
Marking scheme
**(i)**
- 1 mark for correct conversion of '3' to '0011'
- 1 mark for correct conversion of 'D' to '1101'
- 1 mark for fully correct combined 8-bit binary string: '00111101'
**(ii)**
- 1 mark for showing place value multiplication (e.g. \(3 \times 16\) and \(13 \times 1\))
- 1 mark for showing sum of calculations (e.g. \(48 + 13\))
- 1 mark for correct final denary answer: 61
**(b)**
- Max 3 marks:
- 1 mark for stating that hex is easier to read/write/interpret than binary
- 1 mark for stating that debugging is faster/less prone to transcription/typing errors
- 1 mark for explaining that conversions between binary and hex are simple because one hex digit equals exactly 4 bits
**(c)**
**(i)**
- 1 mark for identifying the MSB weight as -128
- 1 mark for summing the positive bits correctly (\(64 + 32 + 8 + 2 + 1 = 107\))
- 1 mark for correct addition working (\(-128 + 107\))
- 1 mark for correct final answer: -21
**(ii)**
- 1 mark for correct binary representation of positive 44: '00101100'
- 1 mark for correct inversion of bits to '11010011'
- 1 mark for correct addition of 1
- 1 mark for correct final 8-bit binary string: '11010100'
**(d)**
**(i)**
- 1 mark for correct shifted binary string: '00010110'
- 1 mark for stating that the shift divides the value
- 1 mark for stating it divides by 8 (or \(2^3\))
- 1 mark for stating that bits are lost on the right / precision is lost
**(ii)**
- 1 mark for stating that the two '1' bits on the left are shifted out / lost
- 1 mark for stating this results in an overflow error
- 1 mark for stating that the resulting stored number is mathematically incorrect / not correctly multiplied by 4
**(e)**
**(i)**
- Max 4 marks (2 marks per distinct point of comparison):
- 1 mark for stating ASCII uses 7/8 bits / 1 mark for contrasting Unicode uses 16/32 bits
- 1 mark for stating ASCII represents a max of 128/256 characters / 1 mark for contrasting Unicode represents over 100,000 characters / global languages
**(ii)**
- 1 mark for correct denary value identification for all three letters (C=67, A=65, B=66)
- 1 mark for correct conversion working for C (e.g., \(64 + 2 + 1\))
- 1 mark for correct binary representation of C: '01000011'
- 1 mark for correct conversion working for A (e.g., \(64 + 1\))
- 1 mark for correct binary representation of A: '01000001'
- 1 mark for correct binary representation of B: '01000010'
Ready to test yourself?
Turn these notes into exam-style practice. Get unlimited AI questions on this topic with instant marking and explanations.
Practice This TopicPaper 21: Algorithms, Programming and Logic
Show answer & marking schemeHide answer & marking scheme
Worked solution
Marking scheme
Show answer & marking schemeHide answer & marking scheme
Worked solution
Marking scheme
Show answer & marking schemeHide answer & marking scheme
Worked solution
Marking scheme
```
01 DECLARE ClassSize : REAL
02 DECLARE Counter : INTEGER
03 DECLARE Score : INTEGER
04 DECLARE Total : REAL
05 Total <- 0
06 ClassSize <- ROUND(RANDOM() * 25, 0) + 15
07 IF Counter <- 1 TO ClassSize
08 OUTPUT "Enter score: "
09 INPUT Score
10 Total <- Total * Score
11 NEXT Counter
12 ClassAverage <- Total * ClassSize
13 OUTPUT "The class total is ", Total
14 OUTPUT "The class average is ", ClassAverage
```
(a) Identify the line numbers of four errors in the pseudocode and write the correct statements. [4]
(b) Explain how you should alter the original corrected algorithm to make sure that all student scores entered are between 0 and 100 inclusive. If any score falls outside these limits, an error message is output, and the user is repeatedly prompted to re-enter a valid score until one is provided.
You do not need to re-write the algorithm. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
* **Error 1**: Line 01
* *Correction*: `DECLARE ClassSize : INTEGER` (The class size must be a whole number of students).
* **Error 2**: Line 07
* *Correction*: `FOR Counter <- 1 TO ClassSize` (A count-controlled loop must begin with `FOR`, not `IF`).
* **Error 3**: Line 10
* *Correction*: `Total <- Total + Score` (To calculate the sum of the scores, they must be added, not multiplied).
* **Error 4**: Line 12
* *Correction*: `ClassAverage <- Total / ClassSize` (The average is calculated by dividing the total by the number of students, not by multiplying).
### Part (b)
To validate that each entered score is between 0 and 100 inclusive:
1. Directly after the score is input on line 09, add a conditional loop (such as a `WHILE` loop).
2. The loop condition must check if the score is invalid: `WHILE Score < 0 OR Score > 100`.
3. Inside the loop, output an error message (e.g., `OUTPUT "Error: Score must be between 0 and 100. Please try again."`).
4. Inside the loop, prompt for and read a replacement score (`INPUT Score`).
5. Close the loop with `ENDWHILE` before adding the score to the total on line 10.
Marking scheme
* 1 mark for identifying Line 01 and correcting to `DECLARE ClassSize : INTEGER`.
* 1 mark for identifying Line 07 and correcting to `FOR Counter <- 1 TO ClassSize`.
* 1 mark for identifying Line 10 and correcting to `Total <- Total + Score`.
* 1 mark for identifying Line 12 and correcting to `ClassAverage <- Total / ClassSize`.
### Part (b) [4 Marks]
Any four points from:
* 1 mark: Identify position for modification (directly after the input on Line 09 / before adding to Total on Line 10).
* 1 mark: Use of a post-input conditional validation loop (e.g., `WHILE ... ENDWHILE` loop).
* 1 mark: Correct validation condition to check for values outside range (`Score < 0 OR Score > 100`).
* 1 mark: Outputting an error message inside the loop.
* 1 mark: Including a re-input statement (`INPUT Score`) inside the loop.
```
01 DECLARE MinTemp : REAL
02 DECLARE ZeroCount : INTEGER
03 DECLARE Day : INTEGER
04 MinTemp <- 0.0
05 ZeroCount <- 0
06 REPEAT Day <- 1 TO 31
07 IF JulyTemps[Day] > MinTemp
08 THEN
09 MinTemp <- JulyTemps[Day]
10 ENDIF
11 IF JulyTemps[Day] = 0.0
12 THEN
13 ZeroCount <- ZeroCount + Day
14 ENDIF
15 NEXT Day
16 OUTPUT "The lowest temperature is ", MinTemp
17 OUTPUT "Number of days at zero degrees is ", ZeroCount
```
(a) Identify the line numbers of four errors in the pseudocode and write the correct statements. [4]
(b) Explain how you should alter the original corrected algorithm to find and output the day of the month (the index of the array) on which the lowest temperature first occurred.
You do not need to re-write the algorithm. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
* **Error 1**: Line 04
* *Correction*: `MinTemp <- JulyTemps[1]` (To find the minimum, initializing to `0.0` is incorrect because any recorded positive values will not be captured as the minimum if they are all above 0. It must be initialized to the first element in the array or a very high default value).
* **Error 2**: Line 06
* *Correction*: `FOR Day <- 1 TO 31` (or `FOR Day <- 2 TO 31` if initialized to `JulyTemps[1]`). The loop is a count-controlled loop but uses the keyword `REPEAT` incorrectly with a range.
* **Error 3**: Line 07
* *Correction*: `IF JulyTemps[Day] < MinTemp` (To find the lowest temperature, we must check if the current element is less than the current minimum, not greater than).
* **Error 4**: Line 13
* *Correction*: `ZeroCount <- ZeroCount + 1` (To count how many days had a temperature of zero, we must increment the count by 1, not add the day's index/number).
### Part (b)
To find and output the day of the month when the lowest temperature first occurred:
1. Declare a new variable to store the day, such as `MinDay : INTEGER`.
2. Initialize this variable to `1` before the loop begins (to correspond with initializing `MinTemp` to `JulyTemps[1]`).
3. Inside the selection block on lines 07-10 (where a new lowest temperature is found), add a statement to update `MinDay` with the current loop counter: `MinDay <- Day`.
4. At the end of the algorithm (after line 15), add an output statement to display this value: `OUTPUT "The lowest temperature first occurred on day ", MinDay`.
Marking scheme
* 1 mark for identifying Line 04 and correcting to `MinTemp <- JulyTemps[1]` (accept a high boundary like `MinTemp <- 100.0` or similar).
* 1 mark for identifying Line 06 and correcting to `FOR Day <- 1 TO 31` (or `FOR Day <- 2 TO 31`).
* 1 mark for identifying Line 07 and correcting to `IF JulyTemps[Day] < MinTemp`.
* 1 mark for identifying Line 13 and correcting to `ZeroCount <- ZeroCount + 1`.
### Part (b) [4 Marks]
Any four points from:
* 1 mark: Declare a new integer variable (e.g., `MinDay`) to hold the index.
* 1 mark: Initialize the new variable to 1 (before entering the loop).
* 1 mark: Identify that the modification happens inside the `THEN` block of the lowest temperature check (lines 08-10).
* 1 mark: Assign the loop counter `Day` to the index variable (e.g., `MinDay <- Day`).
* 1 mark: Add an output statement after the loop to display the index value.
$$X = (\text{NOT } A \text{ AND } B) \text{ OR } (A \text{ XOR NOT } C)$$
(a) Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify this logic expression. [5]
(b) Complete the truth table from the given logic expression. [4]
| A | B | C | Working space | X |
|---|---|---|---|---|
| 0 | 0 | 0 | | |
| 0 | 0 | 1 | | |
| 0 | 1 | 0 | | |
| 0 | 1 | 1 | | |
| 1 | 0 | 0 | | |
| 1 | 0 | 1 | | |
| 1 | 1 | 0 | | |
| 1 | 1 | 1 | | |
Show answer & marking schemeHide answer & marking scheme
Worked solution
- One NOT gate with input A.
- One AND gate with inputs from the output of the first NOT gate and B.
- One NOT gate with input C.
- One XOR gate with inputs A and the output of the second NOT gate.
- One OR gate with inputs from the output of the AND gate and the output of the XOR gate, producing output X.
(b) Completed truth table:
| A | B | C | Working space | X |
|---|---|---|---|---|
| 0 | 0 | 0 | (1 AND 0) OR (0 XOR 1) = 0 OR 1 | 1 |
| 0 | 0 | 1 | (1 AND 0) OR (0 XOR 0) = 0 OR 0 | 0 |
| 0 | 1 | 0 | (1 AND 1) OR (0 XOR 1) = 1 OR 1 | 1 |
| 0 | 1 | 1 | (1 AND 1) OR (0 XOR 0) = 1 OR 0 | 1 |
| 1 | 0 | 0 | (0 AND 0) OR (1 XOR 1) = 0 OR 0 | 0 |
| 1 | 0 | 1 | (0 AND 0) OR (1 XOR 0) = 0 OR 1 | 1 |
| 1 | 1 | 0 | (0 AND 1) OR (1 XOR 1) = 0 OR 0 | 0 |
| 1 | 1 | 1 | (0 AND 1) OR (1 XOR 0) = 0 OR 1 | 1 |
Marking scheme
- 1 mark for NOT gate with input A.
- 1 mark for AND gate with inputs (NOT A) and B.
- 1 mark for NOT gate with input C.
- 1 mark for XOR gate with inputs A and (NOT C).
- 1 mark for final OR gate combining the outputs of the AND and XOR gates to produce output X.
(b) [4 marks total]:
- 4 marks for eight correct outputs.
- 3 marks for six or seven correct outputs.
- 2 marks for four or five correct outputs.
- 1 mark for two or three correct outputs.
$$Y = (P \text{ AND NOT } Q) \text{ NOR } (Q \text{ XOR NOT } R)$$
(a) Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify this logic expression. [5]
(b) Complete the truth table from the given logic expression. [4]
| P | Q | R | Working space | Y |
|---|---|---|---|---|
| 0 | 0 | 0 | | |
| 0 | 0 | 1 | | |
| 0 | 1 | 0 | | |
| 0 | 1 | 1 | | |
| 1 | 0 | 0 | | |
| 1 | 0 | 1 | | |
| 1 | 1 | 0 | | |
| 1 | 1 | 1 | | |
Show answer & marking schemeHide answer & marking scheme
Worked solution
- One NOT gate with input Q.
- One AND gate with inputs P and the output of the first NOT gate.
- One NOT gate with input R.
- One XOR gate with inputs Q and the output of the second NOT gate.
- One NOR gate with inputs from the output of the AND gate and the output of the XOR gate, producing output Y.
(b) Completed truth table:
| P | Q | R | Working space | Y |
|---|---|---|---|---|
| 0 | 0 | 0 | (0 AND 1) NOR (0 XOR 1) = 0 NOR 1 | 0 |
| 0 | 0 | 1 | (0 AND 1) NOR (0 XOR 0) = 0 NOR 0 | 1 |
| 0 | 1 | 0 | (0 AND 0) NOR (1 XOR 1) = 0 NOR 0 | 1 |
| 0 | 1 | 1 | (0 AND 0) NOR (1 XOR 0) = 0 NOR 1 | 0 |
| 1 | 0 | 0 | (1 AND 1) NOR (0 XOR 1) = 1 NOR 1 | 0 |
| 1 | 0 | 1 | (1 AND 1) NOR (0 XOR 0) = 1 NOR 0 | 0 |
| 1 | 1 | 0 | (1 AND 0) NOR (1 XOR 1) = 0 NOR 0 | 1 |
| 1 | 1 | 1 | (1 AND 0) NOR (1 XOR 0) = 0 NOR 1 | 0 |
Marking scheme
- 1 mark for NOT gate with input Q.
- 1 mark for AND gate with inputs P and (NOT Q).
- 1 mark for NOT gate with input R.
- 1 mark for XOR gate with inputs Q and (NOT R).
- 1 mark for final NOR gate combining the outputs of the AND and XOR gates to produce output Y.
(b) [4 marks total]:
- 4 marks for eight correct outputs.
- 3 marks for six or seven correct outputs.
- 2 marks for four or five correct outputs.
- 1 mark for two or three correct outputs.
A database table called Books stores details of books available in a small bookstore.
FieldExample dataBookIDBK9012TitleThe Midnight LibraryGenreFictionPrice12.99Quantity8SupplierIDSUP302OnOrderNo(a) Explain why the field Genre is not suitable to be chosen as a primary key. [1]
(b) Fill in the missing parts of the structured query language (SQL) statement to calculate the total quantity of books in stock supplied by 'SUP302'. [5]
SELECT ............................................. (.............................................)
FROM .............................................
WHERE ............................................. = ............................................. ;
Show answer & marking schemeHide answer & marking scheme
Worked solution
Part (a): The Genre field is not suitable because it contains duplicate values (more than one book can belong to the same genre, so the data is not unique). (1 mark)
Part (b): The completed SQL statement is: SELECT SUM(Quantity) FROM Books WHERE SupplierID = 'SUP302';
- Blank 1: SUM (1 mark)
- Blank 2: Quantity (1 mark)
- Blank 3: Books (1 mark)
- Blank 4: SupplierID (1 mark)
- Blank 5: 'SUP302' (1 mark)
Marking scheme
Part (a): 1 mark for explaining that the Genre field contains duplicate values / is not unique / multiple books can share the same genre.
Part (b): 5 marks total, awarded as follows:
- 1 mark for SUM
- 1 mark for Quantity
- 1 mark for Books
- 1 mark for SupplierID
- 1 mark for 'SUP302' (accept double quotes "SUP302")
The two-dimensional (2D) array LapTimes[] is used to store, for each runner, the times (in minutes) for:
• Lap 1
• Lap 2
• Lap 3
• Lap 4.
The 1D array TotalTimes[] is used to store the total time taken by each runner.
The position of any runner’s data is the same in all three arrays. For example, the data in index 2 of LapTimes[] and index 2 of TotalTimes[] belongs to the runner in index 2 of RunnerNames[].
The variable QualifyingTime stores a threshold time set by the club coach.
Write a program that meets the following requirements:
• allows the qualifying time to be input and stored (must be between 40 and 120 minutes inclusive)
• validates the qualifying time
• allows the names of the 10 runners to be input and stored
• allows the 4 lap times to be input and stored for each runner
• validates each lap time to be between 5 and 30 minutes inclusive, prompting the user to re-enter the lap time if it is outside this range
• calculates and stores the total time for each runner
• finds the runner or runners with the fastest (lowest) total time
• outputs the name or names of the winning runner(s), their total time, and whether they achieved a qualifying time (less than or equal to QualifyingTime).
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; you may assume that this has already been done.
All inputs and outputs must contain suitable messages.
Show answer & marking schemeHide answer & marking scheme
Worked solution
```pseudocode
// Input qualifying time with validation
REPEAT
OUTPUT "Enter the qualifying time (40 to 120 minutes): "
INPUT QualifyingTime
IF QualifyingTime < 40 OR QualifyingTime > 120
THEN
OUTPUT "Invalid qualifying time. Try again."
ENDIF
UNTIL QualifyingTime >= 40 AND QualifyingTime <= 120
// Input runner names and lap times with inner loop validation
FOR Counter <- 1 TO 10
OUTPUT "Enter name for runner ", Counter, ": "
INPUT RunnerNames[Counter]
Total <- 0
FOR Lap <- 1 TO 4
REPEAT
OUTPUT "Enter Lap ", Lap, " time for ", RunnerNames[Counter], ": "
INPUT TempTime
IF TempTime < 5 OR TempTime > 30
THEN
OUTPUT "Lap time must be between 5 and 30 minutes. Please re-enter."
ENDIF
UNTIL TempTime >= 5 AND TempTime <= 30
LapTimes[Counter, Lap] <- TempTime
Total <- Total + TempTime
NEXT Lap
TotalTimes[Counter] <- Total
NEXT Counter
// Finding the fastest runner (minimum time)
MinTime <- 9999
FOR Counter <- 1 TO 10
IF TotalTimes[Counter] < MinTime
THEN
MinTime <- TotalTimes[Counter]
ENDIF
NEXT Counter
// Outputting winner(s) and checking qualifying status (handles ties)
FOR Counter <- 1 TO 10
IF TotalTimes[Counter] = MinTime
THEN
OUTPUT "Winner: ", RunnerNames[Counter]
OUTPUT "Total Time: ", TotalTimes[Counter], " minutes"
IF TotalTimes[Counter] <= QualifyingTime
THEN
OUTPUT "Status: Achieved qualifying time!"
ELSE
OUTPUT "Status: Did not achieve qualifying time."
ENDIF
ENDIF
NEXT Counter
```
Marking scheme
**R1: Input and validation of QualifyingTime (Max 3 marks)**
• Input with prompt for QualifyingTime (1 mark)
• Validation loop (REPEAT...UNTIL or WHILE) ensuring value is between 40 and 120 inclusive (1 mark)
• Correct logical condition in validation loop (1 mark)
**R2: Input of runner names and lap times (Max 4 marks)**
• Outer loop running exactly 10 times to input runner names (1 mark)
• Inner loop running exactly 4 times for each runner to input lap times (1 mark)
• Validation of lap times (between 5 and 30 inclusive) with re-entry prompt if invalid (1 mark)
• Storing validated lap times in 2D array LapTimes[][] (1 mark)
**R3: Calculation of total times (Max 2 marks)**
• Accumulating lap times for each runner inside the inner loop (1 mark)
• Storing the final calculated sum in the TotalTimes[] array at the correct index (1 mark)
**R4: Finding the fastest runner(s) (Max 3 marks)**
• Initializing a variable (e.g. MinTime) with a suitably high initial value (1 mark)
• Iterating through TotalTimes[] to find the absolute minimum value (1 mark)
• Correct logic to update the minimum time (1 mark)
**R5: Output of winner(s) and qualifying status (Max 3 marks)**
• Iterating through to find and output all runners matching the minimum time (handles ties) (1 mark)
• Outputting appropriate messages including runner names, total times (1 mark)
• Correctly comparing winning time against QualifyingTime and outputting appropriate status message (1 mark)
Wondering how well you actually know this?
thinka is an AI practice app for IGCSE & IB students: unlimited questions, instant auto-marking, and detailed step-by-step solutions. 100,000+ students use it to confirm they actually know it, not just think they do.
Want more questions like this? Practice unlimited on thinka, instant answers included.
Start Practicing Free