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)

150 marks210 mins2024
An original Thinka practice paper modelled on the structure and difficulty of the Jun 2024 (V1) Cambridge IGCSE Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.

Paper 11: Computer Systems Theory

Answer all questions. Calculators must not be used. Total marks: 75.
9 Question · 75 marks
Question 1 · short_answer
4 marks
An operating system uses interrupts to manage various events that occur during computer operations. State what is meant by an interrupt and explain how the CPU handles an interrupt once it is detected.
Show answer & marking scheme

Worked solution

An interrupt is a signal sent from a device or software to the processor, requesting its attention and causing the processor to temporarily suspend its current activities. When detected, the CPU handles it as follows: 1. The CPU suspends execution of the current task/instructions. 2. The CPU saves the current status/registers (e.g. Program Counter) of the task to a stack. 3. The CPU calls and runs the appropriate Interrupt Service Routine (ISR) to handle the request. 4. Once the ISR is complete, the saved status is restored, and the CPU resumes the suspended task.

Marking scheme

Award 1 mark for definition, up to 3 marks for handling process: - Definition: Signal sent from a device/software to processor to request attention / suspend current task [1 mark] - Handling: CPU suspends the current process/execution of instructions [1 mark] - Handling: CPU saves the current state/status/registers/Program Counter [1 mark] - Handling: CPU runs the Interrupt Service Routine (ISR) / interrupt handler [1 mark]
Question 2 · short_answer
4 marks
A business uses a proxy server to protect its network. State what a proxy server is and describe three security or performance benefits it provides to a network.
Show answer & marking scheme

Worked solution

A proxy server is an intermediary server that sits between a local client/network and the internet. Three benefits it provides are: 1. Anonymity/IP masking: It hides the internal network IP addresses from external web servers, protecting the network from direct attacks. 2. Web filtering: It can block access to specific websites (e.g. social media or malicious sites) based on company policies. 3. Caching: It stores copies of frequently accessed web pages, reducing internet bandwidth usage and speeding up access for users.

Marking scheme

Award 1 mark for definition, and 1 mark each for any three benefits (max 3): - Definition: Acts as an intermediary/buffer between a local client and the internet [1 mark] - Benefit: IP address masking / prevents direct access to the client machine / anonymity [1 mark] - Benefit: Content filtering / blocks access to malicious or unauthorized websites [1 mark] - Benefit: Caching web pages / speeds up response times / reduces bandwidth usage [1 mark] - Benefit: Inspects incoming/outgoing traffic / acts as a firewall [1 mark]
Question 3 · short_answer
4 marks
A sender transmits a block of data to a receiver. Describe how a checksum is used to detect transmission errors in the block of data.
Show answer & marking scheme

Worked solution

1. Prior to transmission, the sender calculates a checksum value from the block of data using a specific algorithm. 2. The calculated checksum is appended to the data block and transmitted with it. 3. Upon receipt, the receiver performs the same algorithm on the received data block to generate its own checksum. 4. The receiver compares its calculated checksum with the transmitted checksum. If they match, the data is assumed to be error-free; if they do not match, an error is detected and retransmission is typically requested.

Marking scheme

Award 1 mark for each point up to a maximum of 4: - Sender calculates a checksum value using a specific algorithm on the block of data [1 mark] - The checksum value is sent/transmitted along with the block of data [1 mark] - Receiver performs the same calculation/algorithm on the received data [1 mark] - Receiver compares the two checksum values [1 mark] - If the values match, data is correct / if they do not match, an error has occurred / request for retransmission is sent [1 mark]
Question 4 · short_answer
4 marks
An automated greenhouse system maintains the temperature of the air between \( 18^\circ\text{C} \) and \( 25^\circ\text{C} \). Describe how the microprocessor uses data from a temperature sensor to control the greenhouse temperature.
Show answer & marking scheme

Worked solution

The process operates as follows: 1. The temperature sensor continuously takes readings of the greenhouse air temperature. 2. These analogue readings are converted to digital signals using an Analogue-to-Digital Converter (ADC) so the microprocessor can process them. 3. The microprocessor compares the digital readings to the pre-set range of \( 18^\circ\text{C} \) to \( 25^\circ\text{C} \). 4. If the reading is below \( 18^\circ\text{C} \), the microprocessor sends a signal to an actuator to turn on the heater. If the reading is above \( 25^\circ\text{C} \), it sends a signal to turn on the fan/turn off the heater. This cycle repeats continuously.

Marking scheme

Award 1 mark per point up to a maximum of 4: - Microprocessor receives data/readings from the sensor continuously / at intervals [1 mark] - Sensor data is converted from analogue to digital / using an ADC [1 mark] - Microprocessor compares the readings to stored/pre-set values (\( 18^\circ\text{C} \) and \( 25^\circ\text{C} \)) [1 mark] - If reading is below \( 18^\circ\text{C} \), a signal is sent to (an actuator to) turn on the heater / if above \( 25^\circ\text{C} \), a signal is sent to turn on the fan [1 mark] - This is a continuous/looping process [1 mark]
Question 5 · long structured explanation
7 marks
A customer is logging into their online banking account. The web browser uses Transport Layer Security (TLS) to secure the connection to the bank's web server.

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 scheme

Worked solution

1. The web browser requests a secure connection to the bank's web server (via HTTPS).
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

Award 1 mark for each valid point up to a maximum of 7 marks:
- 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
Question 6 · long structured explanation
7 marks
A research facility uses an automated system to control the temperature inside a tropical plant dome.

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 scheme

Worked solution

1. A temperature sensor is placed inside the dome to continuously take measurements of the ambient air temperature.
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

Award 1 mark for each valid point up to a maximum of 7 marks:
- 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
Question 7 · long structured explanation
7 marks
A company transmits a large file containing transaction records across a network. A checksum is used to detect whether any data corruption has occurred during transmission.

Describe how a checksum is generated, transmitted, and used to verify the integrity of the data.
Show answer & marking scheme

Worked solution

1. Prior to transmission, the sending device splits the file into blocks of data.
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

Award 1 mark for each valid point up to a maximum of 7 marks:
- 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)
Question 8 · structured
4 marks
A 12-bit register contains the following binary value:

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 scheme

Worked solution

Step 1: Perform a logical right shift of 2 places on the initial value 110110010101.
- 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

After logical right shift of 2 places:
- 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)
Question 9 · logical conversion scenario
34 marks
A digital system on an environmental research buoy collects sensor data and processes it before wireless transmission.

**(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 scheme

Worked solution

Detailed step-by-step solutions:

**(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

**(a)**
**(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 Topic

Paper 21: Algorithms, Programming and Logic

Answer all questions. Use of pseudocode or high-level programming code is mandatory where requested. Total marks: 75.
9 Question · 64 marks
Question 1 · matching
3 marks
Three descriptions of loop structures used in pseudocode are shown below. Identify the correct loop type for each description from this list: REPEAT...UNTIL, FOR...TO...NEXT, WHILE...DO...ENDWHILE. 1. A loop that will always execute at least once because its termination condition is evaluated at the end of the iteration. 2. A loop that is controlled by a control variable that starts at a specified value and increments until it reaches a final value. 3. A loop that may execute zero times because its continuation condition is tested before any statements are executed.
Show answer & marking scheme

Worked solution

1. REPEAT...UNTIL is a post-condition loop, so it always executes at least once. 2. FOR...TO...NEXT is a count-controlled loop that automatically increments a control variable. 3. WHILE...DO...ENDWHILE is a pre-condition loop, which can execute zero times if the condition is false initially.

Marking scheme

One mark for each correct loop type identified: 1. REPEAT...UNTIL (Accept: REPEAT loop / post-condition loop) 2. FOR...TO...NEXT (Accept: FOR loop / count-controlled loop) 3. WHILE...DO...ENDWHILE (Accept: WHILE loop / pre-condition loop)
Question 2 · matching
3 marks
Three descriptions of validation checks are shown below. Identify the validation check being described in each case. 1. A check that determines if a required data item contains only digits or only letters. 2. A check that determines whether an input box has been completely bypassed by the user. 3. A check that determines if the entered string has exactly eight characters.
Show answer & marking scheme

Worked solution

1. A type check validates that the data is of the correct data type (e.g. integer vs. string). 2. A presence check ensures that a field contains data and cannot be left blank. 3. A length check confirms if the input contains a specific number of characters (or is within a specified range).

Marking scheme

One mark for each correct validation check: 1. Type check (Accept: character/numeric check) 2. Presence check 3. Length check
Question 3 · matching
3 marks
Three pseudocode array declarations are shown below. Identify the maximum number of elements (storage locations) that can be stored in each array. 1. DECLARE SensorData : ARRAY[1:50] OF REAL; 2. DECLARE GridMap : ARRAY[0:8, 1:10] OF CHAR; 3. DECLARE MonthlySales : ARRAY[1:12, 1:4] OF INTEGER
Show answer & marking scheme

Worked solution

1. Index range 1 to 50 contains 50 elements. 2. Index range 0 to 8 contains 9 elements. Index range 1 to 10 contains 10 elements. Total elements = 9 * 10 = 90 elements. 3. Index range 1 to 12 contains 12 elements. Index range 1 to 4 contains 4 elements. Total elements = 12 * 4 = 48 elements.

Marking scheme

One mark for each correct number of elements: 1. 50; 2. 90; 3. 48
Question 4 · written
8 marks
An algorithm is intended to determine a class size at random (between 15 and 40 students inclusive), allow a test score out of 100 to be entered for each student, calculate the total score, and then calculate the class average. The class total and average are output at the end of the algorithm.

```
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 scheme

Worked solution

### Part (a)

* **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

### Part (a) [4 Marks]
* 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.
Question 5 · written
8 marks
A 1D array `JulyTemps[]` contains 31 recorded temperatures for the month of July. A pseudocode algorithm is intended to find the lowest temperature recorded during the month, and count how many days recorded a temperature of exactly 0 degrees. The lowest temperature and the count are output at the end of the algorithm.

```
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 scheme

Worked solution

### Part (a)

* **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

### Part (a) [4 Marks]
* 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.
Question 6 · theory
9 marks
Consider the logic expression:

$$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 scheme

Worked solution

(a) The logic circuit should contain the following gates:
- 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

(a) [5 marks total]:
- 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.
Question 7 · theory
9 marks
Consider the logic expression:

$$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 scheme

Worked solution

(a) The logic circuit should contain the following gates:
- 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

(a) [5 marks total]:
- 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.
Question 8 · structural
6 marks

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 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")
Question 9 · scenario
15 marks
10 The one-dimensional (1D) array RunnerNames[] is used to store the names of 10 runners in a local athletics club.

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 scheme

Worked solution

An elegant solution written in standard pseudocode:

```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

Marks are awarded using the standard 15-mark grid based on the following requirements:

**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