An original Thinka practice paper modelled on the structure and difficulty of the Nov 2023 (V3) Cambridge International A Level Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
Paper 1 Computer Systems
Answer all questions. Calculators are not permitted. Show working for conversions and logic designs.
11 Question · 60 marks
Question 1 · short_answer
3 marks
Convert the denary number 147 into an 8-bit binary number and then convert that binary value into its hexadecimal equivalent. Show your working.
Show answer & marking schemeHide answer & marking scheme
Worked solution
To convert 147 to binary: 147 = 128 + 16 + 2 + 1, which gives 10010011 in 8-bit binary. To convert 10010011 to hex: split into two nibbles: 1001 (= 9 in denary/hex) and 0011 (= 3 in denary/hex). Combining them gives 93 in hexadecimal.
Marking scheme
1 mark for correct 8-bit binary representation (10010011). 1 mark for correct hexadecimal representation (93). 1 mark for showing correct working (either showing binary decomposition or nibble splitting).
Question 2 · short_answer
3 marks
State three different scenarios or events that would generate an interrupt in a computer system.
Show answer & marking schemeHide answer & marking scheme
Worked solution
An interrupt is a signal sent to the processor that temporarily suspends current execution. Common scenarios include hardware errors (e.g. printer paper jam, low battery), user inputs (e.g. keyboard key press, mouse click), or software-generated errors (e.g. division by zero, buffer overflow).
Marking scheme
1 mark for each valid scenario up to a maximum of 3 marks. Do not accept general terms like 'running a program' without specific interrupt causes.
Question 3 · short_answer
3 marks
An automated greenhouse system uses a soil moisture sensor to maintain soil humidity. Explain how the sensor, microprocessor, and an actuator work together to keep the soil at the correct moisture levels.
Show answer & marking schemeHide answer & marking scheme
Worked solution
1. Soil moisture sensor continuously measures moisture levels and sends data to the microprocessor (analogue signals are converted to digital using an ADC). 2. The microprocessor compares the digital readings to preset threshold values. 3. If the moisture level is below the threshold, the microprocessor sends a signal to the actuator (e.g., water pump or valve) to turn it on.
Marking scheme
1 mark for explaining that the sensor measures moisture and sends digital data to the microprocessor. 1 mark for explaining that the microprocessor compares this data to preset values. 1 mark for explaining that the microprocessor sends a signal to the actuator to act if the condition is met.
Question 4 · short_answer
3 marks
Explain how a checksum is used to detect errors during data transmission.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Before transmission, the sending device applies an algorithm to the data block to calculate a checksum value. This value is transmitted alongside the data. The receiving device recalculates the checksum using the exact same algorithm on the received data. Finally, the receiver compares the two checksum values; if they do not match, a transmission error is detected and a retransmission is requested.
Marking scheme
1 mark for stating that the sender calculates a checksum from the data before transmission. 1 mark for stating that the checksum is sent along with the data. 1 mark for stating that the receiver recalculates the checksum and compares it, indicating an error if they mismatch.
Question 5 · short_answer
3 marks
An expert system is used to assist doctors in diagnosing medical conditions. Identify the three main components of an expert system and state their purpose.
Show answer & marking schemeHide answer & marking scheme
Worked solution
An expert system consists of three primary components: 1. User Interface: The screen/form through which the doctor inputs symptoms and receives the diagnosis. 2. Knowledge Base: The database containing the accumulated facts and rules from medical experts. 3. Inference Engine: The processing engine that applies rules to facts to draw logical conclusions and make diagnoses.
Marking scheme
1 mark for identifying the User Interface and its purpose of facilitating user interaction. 1 mark for identifying the Knowledge Base and its purpose of storing facts and rules. 1 mark for identifying the Inference Engine and its purpose of applying rules to facts to reach a conclusion.
Question 6 · Explanatory / Scenario-based
8 marks
A scientific research team is launching a high-altitude weather balloon to record atmospheric telemetry and capture high-definition video. The onboard computer system needs a storage drive to record this data.
(a) Recommend the most suitable type of storage medium (Solid State Drive (SSD) vs Magnetic Hard Disk Drive (HDD)) for this specific application. Explain three reasons for your choice, referring to the physical conditions the balloon will experience. [4]
(b) Explain how Solid State memory (NAND flash) physically stores data. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) Recommended medium: Solid State Drive (SSD) / Flash Memory. Reasons: 1. No moving parts: SSDs are highly resistant to physical shocks, vibrations, and high G-forces experienced during balloon launch, ascent, and landing/impact, whereas HDDs have spinning platters and read/write heads that can be easily damaged or misaligned. 2. Lightweight: SSDs have a significantly lower mass/weight compared to HDDs, which reduces the total payload weight of the balloon, helping it reach higher altitudes. 3. Lower power consumption: SSDs do not require an electric motor to spin magnetic platters, meaning they use less power, preserving the balloon's battery life in extreme conditions. 4. Temperature tolerance: SSDs can operate reliably across a much wider temperature range than HDDs, which are prone to failure at extremely low temperatures due to lubricant contraction or mechanical seizing.
(b) NAND flash memory physical operation: 1. NAND flash memory contains millions of tiny memory cells arranged in a grid. 2. Each cell consists of a floating gate transistor designed to store an electrical charge. 3. High voltage is used to push/trap electrons into the floating gate (tunnel injection) or remove them. 4. The presence or absence of trapped electrons (charge) changes the conductivity of the cell, which is read as a binary '1' or '0'. 5. NAND flash is non-volatile, so it retains these electrical charges (the stored data) even when the power supply is completely disconnected.
Marking scheme
(a) [4 marks] - 1 mark for recommending Solid State Drive / SSD / Flash memory. - 1 mark each for any three valid reasons linked to scenario (e.g., no moving parts/durability against shock/vibration, lightweight/payload limits, lower power consumption/battery preservation, operating temperature limits). - Note: Do NOT award marks for speed unless linked to high-definition video recording bandwidth, but durability/weight/power/temperature are much more critical to the balloon scenario.
(b) [4 marks] - 1 mark for identifying NAND flash consists of transistors / memory cells. - 1 mark for mentioning the floating gate (transistor) / trapping electrons. - 1 mark for explaining that trapping/removing charge (electrons) determines the binary state (1 or 0) / cell conductivity. - 1 mark for stating that NAND flash is non-volatile memory (keeps data without power).
Question 7 · Explanatory / Scenario-based
8 marks
A data transmission system uses a two-dimensional Even Parity check to detect and correct single-bit errors.
(a) Identify the row number and column number of the single-bit transmission error, and explain how the system uses the parity checks to locate and correct this error. [4]
(b) Explain how a Checksum is used to detect transmission errors, highlighting the actions of both the sender and the receiver. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) Row and Column identification: - Row 3 has a parity error. (The row contains three 1s: 1+0+0+1+1+0+0 = 3, plus parity bit 0 = 3, which is odd instead of even). - Column 3 has a parity error. (The column contains one 1: 0+1+0+1 = 2, plus parity row bit 1 = 3, which is odd instead of even). - The error is located at the intersection of Row 3 and Column 3. - To correct the error, the value at Row 3, Column 3 (currently 0) is flipped to 1.
(b) Checksum process: 1. Before transmission, the sender calculates a checksum value using a specific algorithm applied to the block of data (e.g., summing all the byte values). 2. The calculated checksum value is appended to the data packet and transmitted. 3. On receipt of the data, the receiver performs the same calculation/algorithm on the received block of data to generate its own checksum. 4. The receiver compares its calculated checksum with the received checksum value. If they are equal, the data is assumed correct; if they differ, an error has occurred, and the receiver requests a retransmission.
Marking scheme
(a) [4 marks] - 1 mark for correctly identifying that Row 3 has an odd number of 1s (fails parity check). - 1 mark for correctly identifying that Column 3 has an odd number of 1s (fails parity check). - 1 mark for explaining that the intersection of Row 3 and Column 3 pinpoints the faulty bit. - 1 mark for stating that the bit value at Row 3, Column 3 must be inverted/flipped from 0 to 1.
(b) [4 marks] - 1 mark for explaining that the sender calculates a checksum value using an algorithm on the data block. - 1 mark for stating that the checksum is transmitted along with the data block. - 1 mark for explaining that the receiver recalculates the checksum using the same algorithm. - 1 mark for explaining that the receiver compares the two values: if they match, no error; if they do not match, an error is detected (and retransmission is requested).
Question 8 · Explanatory / Scenario-based
8 marks
A chemical processing plant uses three sensors to monitor a storage tank: - Sensor A: Temperature (1 if high, 0 if normal) - Sensor B: Pressure (1 if high, 0 if normal) - Sensor C: Release Valve (1 if open, 0 if closed)
An alarm (X) must sound (output a 1) if: - The temperature (A) is high AND the release valve (C) is closed (0) OR - The pressure (B) is high AND the release valve (C) is closed (0).
(a) Write the Boolean logic expression representing the alarm system using the inputs A, B, and C. [2]
(b) Construct a truth table for this alarm system, showing all eight possible input combinations and the output X. [4]
(c) Explain how this logic expression can be simplified using Boolean algebra properties to use fewer logic gates, and list the logic gates needed for the simplified version. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) Boolean expression: \(X = (A \text{ AND NOT } C) \text{ OR } (B \text{ AND NOT } C)\)
(c) Simplification: - By applying the distributive law, the common term \text{NOT } C can be factored out: \(X = (A \text{ OR } B) \text{ AND NOT } C\) - The logic gates required for this simplified version are: 1. One OR gate (to find \(A \text{ OR } B\)) 2. One NOT gate (to find \text{NOT } C) 3. One AND gate (to combine them)
Marking scheme
(a) [2 marks] - 2 marks for the correct logic expression: \(X = (A \text{ AND NOT } C) \text{ OR } (B \text{ AND NOT } C)\). - Accept alternative standard notations: \(X = (A \cdot \overline{C}) + (B \cdot \overline{C})\) or \(X = (A \land \neg C) \lor (B \land \neg C)\). - Award 1 mark if one of the terms is correct (e.g., \(A \text{ AND NOT } C\)) or if there is a minor syntax error.
(b) [4 marks] - 4 marks for all 8 rows correct. - 3 marks for 6 or 7 rows correct. - 2 marks for 4 or 5 rows correct. - 1 mark for 2 or 3 rows correct. - 0 marks for 0 or 1 row correct. - Expected outputs: (0,0,0) -> 0; (0,0,1) -> 0; (0,1,0) -> 1; (0,1,1) -> 0; (1,0,0) -> 1; (1,0,1) -> 0; (1,1,0) -> 1; (1,1,1) -> 0.
(c) [2 marks] - 1 mark for the correct simplified expression: \(X = (A \text{ OR } B) \text{ AND NOT } C\) or equivalent notation. - 1 mark for listing the correct set of gates: 1 OR gate, 1 NOT gate, and 1 AND gate.
Question 9 · Data Conversion & Arithmetic
13 marks
Answer all parts of the question. Show your working.
(a) Convert the denary number \(154\) into: (i) an 8-bit unsigned binary register. [2] (ii) a Hexadecimal value. [2]
(b) Perform binary addition on the following two 8-bit unsigned binary numbers: \(\begin{array}{r@{\quad}l} & 10110110 \\ + & 01101101 \\ \hline \end{array}\)
Show your working, state the result, and identify the specific storage issue that occurs. [4]
(c) Convert the negative denary number \(-45\) into an 8-bit Two's Complement binary number. Show your working. [3]
(d) Convert the Hexadecimal value \(\text{A7}\) into a denary value. Show your working. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a)(i) To convert \(154\) to binary, determine which power of 2 fit into the number: \(154 - 128 = 26\) \(26 - 16 = 10\) \(10 - 8 = 2\) \(2 - 2 = 0\) This gives: \(128 + 16 + 8 + 2\) which in 8-bit binary is \(10011010\).
(ii) To convert \(10011010\) to Hexadecimal, split into two 4-bit nibbles: \(1001 = 9\) \(1010 = 10 = \text{A}\) Combine them to get \(9\text{A}\).
(b) Adding the two binary numbers: \(10110110 + 01101101\): \(0 + 1 = 1\) \(1 + 0 = 1\) \(1 + 1 = 0\) (carry 1) \(0 + 1 + 1\text{ (carry)} = 0\) (carry 1) \(1 + 0 + 1\text{ (carry)} = 0\) (carry 1) \(1 + 1 + 1\text{ (carry)} = 1\) (carry 1) \(0 + 1 + 1\text{ (carry)} = 0\) (carry 1) \(1 + 0 + 1\text{ (carry)} = 0\) (carry 1) This yields a final 9-bit result: \(100100011\). Because the register is only 8 bits, the leftmost '1' causes an **overflow error**.
(c) To represent \(-45\) in 8-bit Two's Complement: 1. Convert positive \(+45\) to binary: \(00101101\). 2. Invert all the bits (One's Complement): \(11010010\). 3. Add 1 to the result: \(11010011\).
(d) To convert \(\text{A7}\) from Hexadecimal to Denary: \(\text{A} = 10\) \((10 \times 16) + 7 = 160 + 7 = 167\).
Marking scheme
Part (a)(i) [2 marks]: - 1 mark for correct working (e.g., table structure, division method, or sum of powers). - 1 mark for correct binary value: 10011010.
Part (a)(ii) [2 marks]: - 1 mark for showing split of nibbles or division by 16. - 1 mark for correct hexadecimal value: 9A.
Part (b) [4 marks]: - 1 mark for showing correct column addition carries. - 1 mark for correct binary sum (either 100100011 or the 8-bit part 00100011). - 1 mark for identifying the issue as an "overflow error". - 1 mark for explaining that the result is 9 bits and cannot fit in an 8-bit register.
Part (c) [3 marks]: - 1 mark for writing positive 45 in binary (00101101). - 1 mark for showing the correct conversion step (either One's Complement 11010010 or correct mental math using place values \(-128, 64, \dots\)). - 1 mark for correct final binary representation: 11010011.
Part (d) [2 marks]: - 1 mark for showing correct conversion working: (10 * 16) + 7. - 1 mark for correct denary value: 167.
Question 10 · Diagram Design
4 marks
An automated greenhouse ventilation system sounds a buzzer (Z = 1) when conditions are outside safe ranges.
The system uses three sensors: - Sensor A (1 if temperature is high, 0 otherwise) - Sensor B (1 if humidity is high, 0 otherwise) - Sensor C (1 if CO2 level is high, 0 otherwise)
The buzzer must sound (Z = 1) if: - temperature is high AND humidity is high OR - humidity is NOT high AND CO2 level is high
A system designer starts to design the logic circuit for this system. They plan to connect the sensors to four logic gates, labeled Gate 1, Gate 2, Gate 3, and Gate 4, connected as follows: - Input A and Input B are connected to the inputs of Gate 1. - Input B is connected to the input of Gate 2. - The output of Gate 2 and Input C are connected to the inputs of Gate 3. - The output of Gate 1 and the output of Gate 3 are connected to the inputs of Gate 4, which produces the final output Z.
Identify the four logic gates required to complete this design.
- Gate 1: - Gate 2: - Gate 3: - Gate 4:
Show answer & marking schemeHide answer & marking scheme
Worked solution
To design the circuit correctly from the problem statement, we translate the conditions into Boolean logic terms:
1. "temperature is high AND humidity is high" is represented by the expression: A AND B. Since input A and input B are connected to Gate 1, Gate 1 must be an AND gate. 2. "humidity is NOT high" is represented by the expression: NOT B. Since input B is connected to Gate 2, Gate 2 must be a NOT gate. 3. "humidity is NOT high AND CO2 level is high" is represented by the expression: (NOT B) AND C. Since the output of Gate 2 (NOT B) and input C are connected to Gate 3, Gate 3 must be an AND gate. 4. These two main conditions are joined by OR ("OR... humidity is NOT high..."). Therefore, the outputs of Gate 1 and Gate 3 must be combined using an OR gate. Since these outputs are connected to Gate 4, Gate 4 must be an OR gate.
Marking scheme
Award 1 mark for each correct gate up to a maximum of 4 marks: - Gate 1: AND (1 mark) - Gate 2: NOT (1 mark) - Gate 3: AND (1 mark) - Gate 4: OR (1 mark)
Accept lowercase equivalents (and, not, or).
Question 11 · Diagram Design
4 marks
An automated greenhouse ventilation system sounds a buzzer (Z = 1) when conditions are outside safe ranges.
The system uses three sensors: - Sensor A (1 if temperature is high, 0 otherwise) - Sensor B (1 if humidity is high, 0 otherwise) - Sensor C (1 if CO2 level is high, 0 otherwise)
The buzzer must sound (Z = 1) if: - temperature is high AND humidity is high OR - humidity is NOT high AND CO2 level is high
A system designer starts to design the logic circuit for this system. They plan to connect the sensors to four logic gates, labeled Gate 1, Gate 2, Gate 3, and Gate 4, connected as follows: - Input A and Input B are connected to the inputs of Gate 1. - Input B is connected to the input of Gate 2. - The output of Gate 2 and Input C are connected to the inputs of Gate 3. - The output of Gate 1 and the output of Gate 3 are connected to the inputs of Gate 4, which produces the final output Z.
Identify the four logic gates required to complete this design.
- Gate 1: - Gate 2: - Gate 3: - Gate 4:
Show answer & marking schemeHide answer & marking scheme
Worked solution
To design the circuit correctly from the problem statement, we translate the conditions into Boolean logic terms:
1. "temperature is high AND humidity is high" is represented by the expression: A AND B. Since input A and input B are connected to Gate 1, Gate 1 must be an AND gate. 2. "humidity is NOT high" is represented by the expression: NOT B. Since input B is connected to Gate 2, Gate 2 must be a NOT gate. 3. "humidity is NOT high AND CO2 level is high" is represented by the expression: (NOT B) AND C. Since the output of Gate 2 (NOT B) and input C are connected to Gate 3, Gate 3 must be an AND gate. 4. These two main conditions are joined by OR ("OR... humidity is NOT high..."). Therefore, the outputs of Gate 1 and Gate 3 must be combined using an OR gate. Since these outputs are connected to Gate 4, Gate 4 must be an OR gate.
Marking scheme
Award 1 mark for each correct gate up to a maximum of 4 marks: - Gate 1: AND (1 mark) - Gate 2: NOT (1 mark) - Gate 3: AND (1 mark) - Gate 4: OR (1 mark)
Accept lowercase equivalents (and, not, or).
Paper 2 Algorithms, Programming and Logic
Answer all questions. Write all programs in structured pseudocode or standard high-level languages.
10 Question · 73 marks
Question 1 · multiple_choice
1 marks
Consider the following pseudocode algorithm:
DECLARE X : INTEGER DECLARE Y : INTEGER X <- 15 Y <- 4 WHILE X > Y DO X <- X - Y Y <- Y + 1 ENDWHILE
What are the final values of X and Y after this algorithm has run?
A. X = 11, Y = 5 B. X = 6, Y = 6 C. X = 0, Y = 7 D. X = 6, Y = 5
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let us trace the algorithm step-by-step: 1. Initially, X is set to 15 and Y is set to 4. 2. The loop condition is X > Y. Since 15 > 4 is True, the loop starts. 3. X becomes X - Y (15 - 4 = 11). Y becomes Y + 1 (4 + 1 = 5). 4. Check the condition again: 11 > 5 is True, so the loop continues. 5. X becomes X - Y (11 - 5 = 6). Y becomes Y + 1 (5 + 1 = 6). 6. Check the condition again: 6 > 6 is False, so the loop terminates. 7. The final values are X = 6 and Y = 6. This corresponds to Option B.
Marking scheme
Award 1 mark for the correct selection of Option B.
Question 2 · multiple_choice
1 marks
Consider the following pseudocode algorithm that processes a 1D array:
Temp <- 1 FOR Index <- 2 TO 5 IF Scores[Index] < Scores[Temp] THEN Temp <- Index ENDIF NEXT Index
What is the final value of the variable Temp after the code has completed execution?
A. 1 B. 2 C. 4 D. 5
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let us trace the FOR loop step-by-step: - Initially, Temp is set to 1. - Index = 2: Scores[2] is 8, and Scores[Temp] (Scores[1]) is 12. Since 8 < 12 is True, Temp is updated to 2. - Index = 3: Scores[3] is 15, and Scores[Temp] (Scores[2]) is 8. Since 15 < 8 is False, Temp remains 2. - Index = 4: Scores[4] is 5, and Scores[Temp] (Scores[2]) is 8. Since 5 < 8 is True, Temp is updated to 4. - Index = 5: Scores[5] is 10, and Scores[Temp] (Scores[4]) is 5. Since 10 < 5 is False, Temp remains 4. - The loop ends. The final value of Temp is 4, which is the array index of the minimum element (5). This matches Option C.
Marking scheme
Award 1 mark for the correct selection of Option C.
Question 3 · Structured Pseudocode & Tracing
7 marks
An algorithm is designed to process an array of six integers named Data and copy any unique elements (elements that only appear once in the array) into another array named Temp.
The algorithm is written in pseudocode as follows:
DECLARE Data : ARRAY[1:6] OF INTEGER DECLARE Temp : ARRAY[1:6] OF INTEGER DECLARE i, k, Count, j : INTEGER
j <-- 1 FOR i <-- 1 TO 6 Count <-- 0 FOR k <-- 1 TO 6 IF Data[i] = Data[k] THEN Count <-- Count + 1 ENDIF NEXT k IF Count = 1 THEN Temp[j] <-- Data[i] j <-- j + 1 ENDIF NEXT i
Trace the execution of this algorithm by tracking how the values of i, k, Count, j, Temp[1], and Temp[2] change. State the final values of these variables after the algorithm completes.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let's trace the loop executions step-by-step: - i = 1: Data[1] = 12. Compare with all elements. 12 matches at k = 1 and k = 3. Count = 2. Since Count is not 1, Temp is unchanged and j remains 1. - i = 2: Data[2] = 15. Matches at k = 2 and k = 5. Count = 2. Temp is unchanged, j remains 1. - i = 3: Data[3] = 12. Matches at k = 1 and k = 3. Count = 2. Temp is unchanged, j remains 1. - i = 4: Data[4] = 18. Only matches at k = 4. Count = 1. Temp[j] (Temp[1]) becomes 18. j increments to 2. - i = 5: Data[5] = 15. Matches at k = 2 and k = 5. Count = 2. Temp is unchanged, j remains 2. - i = 6: Data[6] = 9. Only matches at k = 6. Count = 1. Temp[j] (Temp[2]) becomes 9. j increments to 3.
At the end of the loop, the final values are: - i = 6 - k = 6 - Count = 1 - j = 3 - Temp[1] = 18 - Temp[2] = 9
Marking scheme
- 1 mark: Correctly tracing the loop variable i (ends at 6). - 1 mark: Correctly tracing the nested loop variable k (ends at 6). - 2 marks: Correctly calculating the correct Count values for all i iterations (2, 2, 2, 1, 2, 1). Deduct 1 mark for any incorrect Count value. - 1 mark: Correctly tracing variable j starting at 1, changing to 2 when i = 4, and ending at 3 when i = 6. - 1 mark: Correctly assigning 18 to Temp[1]. - 1 mark: Correctly assigning 9 to Temp[2].
Question 4 · Structured Pseudocode & Tracing
7 marks
A programmer needs to write a pseudocode algorithm that inputs students' test marks. The algorithm must: - Validate that each mark is between 0 and 100 inclusive. - Add valid marks to a total and increment a count of valid marks. - Count any invalid marks entered. - End input when -1 is entered. - Calculate and output the average of the valid marks (if any were entered). - Output the total number of invalid marks.
Complete the following pseudocode by filling in the blanks numbered (1) to (7).
DECLARE Mark, Total, ValidCount, InvalidCount : INTEGER DECLARE Average : REAL Total <-- 0 ValidCount <-- 0 InvalidCount <-- 0 OUTPUT "Enter mark (or -1 to stop): " INPUT Mark WHILE Mark <> -1 DO IF Mark >= 0 ___(1)___ Mark <= 100 THEN Total <-- Total + ___(2)___ ValidCount <-- ___(3)___ + 1 ELSE InvalidCount <-- ___(4)___ ___(5)___ OUTPUT "Enter mark (or -1 to stop): " INPUT Mark ENDWHILE IF ValidCount > 0 THEN Average <-- ___(6)___ OUTPUT "Average valid mark: ", Average ELSE OUTPUT "No valid marks entered." ENDIF OUTPUT "Number of invalid marks: ", ___(7)___
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let's evaluate each blank to fulfill the logic: - (1) requires a logical operator to ensure BOTH conditions are met (0 to 100 inclusive), which is AND. - (2) adds the current valid input to the running total, which is Mark. - (3) increments the running total count of valid marks, which is ValidCount. - (4) increments the count of invalid marks, which is InvalidCount + 1. - (5) closes the IF statement block, which is ENDIF. - (6) calculates the average by dividing the total of valid marks by the count of valid marks, which is Total / ValidCount. - (7) outputs the final total of invalid marks, which is InvalidCount.
Marking scheme
- 1 mark for (1): AND - 1 mark for (2): Mark - 1 mark for (3): ValidCount - 1 mark for (4): InvalidCount + 1 - 1 mark for (5): ENDIF - 1 mark for (6): Total / ValidCount - 1 mark for (7): InvalidCount
Accept case-insensitive variations (e.g., and, endif). Do not accept symbols like && for AND.
Question 5 · Structured Pseudocode & Tracing
7 marks
Write a pseudocode algorithm to process a pre-populated 1D array named Temps containing 50 temperature readings (as REAL values) stored in indices 1 to 50.
The algorithm must: - Find the maximum temperature in the array. - Count how many times this maximum temperature occurs in the array. - Output both the maximum temperature and the count with appropriate messages.
Use structured pseudocode in your answer.
Show answer & marking schemeHide answer & marking scheme
Worked solution
To find both the maximum temperature and its frequency, we first initialize the maximum value to the first element in the array (Temps[1]) and set our frequency count to 1. We then loop through the remaining elements (index 2 to 50) of the array. For each element, if it is greater than our current maximum, we update the maximum to this new temperature and reset our frequency counter back to 1. If the element is equal to our current maximum, we increment the frequency counter. At the end of the loop, we output both the calculated maximum value and its frequency.
Marking scheme
- 1 mark: Initializing maximum temperature to Temps[1] and initializing frequency count to 1 (or appropriate initialization values such as a very low value and 0 count). - 1 mark: Setting up a loop to iterate through the array from 1 (or 2) to 50. - 1 mark: Correct conditional statement checking if the current element is greater than the current maximum temperature. - 1 mark: Updating maximum temperature to the current element when a higher value is found. - 1 mark: Resetting the frequency count to 1 when a new higher maximum temperature is set. - 1 mark: Correct conditional statement to check if the current temperature equals the maximum temperature, and incrementing the count by 1 in this case. - 1 mark: Printing/outputting both the final maximum temperature and the count with appropriate messages.
Question 6 · Structured Pseudocode & Tracing
7 marks
A programmer has written a pseudocode function named FindFactorial to calculate and return the factorial of any positive integer N (where N >= 1). For example, if N is 4, the function should calculate 4 * 3 * 2 * 1 = 24. However, the code contains three logic errors.
FUNCTION FindFactorial(N : INTEGER) RETURNS INTEGER DECLARE Result, Loop : INTEGER Result <-- 0 FOR Loop <-- 1 TO N Result <-- Result + Loop NEXT Loop RETURN N ENDFUNCTION
Identify the three errors, explain why each is an error, and provide the corrected pseudocode line for each. Finally, state what type of error these represent.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let's analyze the function: 1. The variable Result is initialized to 0. Since calculating factorials involves repeated multiplication, initializing to 0 would lead to a final product of 0 once corrected to multiply. It must be initialized to 1. 2. Inside the FOR loop, the code performs addition (Result <-- Result + Loop) instead of multiplication. Factorial is a product, so we must multiply (Result <-- Result * Loop). 3. The RETURN statement returns the input parameter N instead of returning the computed variable Result. 4. Since the code runs without crashing but produces incorrect results, these are classified as logic errors.
Marking scheme
- 2 marks: Identifying that initializing Result to 0 is incorrect (1 mark) and providing the correction: "Result <-- 1" (1 mark). - 2 marks: Identifying that addition is used inside the loop instead of multiplication (1 mark) and providing the correction: "Result <-- Result * Loop" (1 mark). - 2 marks: Identifying that returning N is incorrect because it outputs the input value (1 mark) and providing the correction: "RETURN Result" (1 mark). - 1 mark: Identifying the category of errors as "Logic error(s)".
Question 7 · Logic Circuit Layout
11 marks
An automated greenhouse ventilation system controls a window motor (W). The window is opened (W = 1) when the system detects specific conditions based on three inputs: - Temperature is high (T = 1) - Humidity is high (H = 1) - Manual override switch is ON (M = 1)
The window opens (W = 1) if: - Temperature is high AND humidity is high OR - Manual override switch is ON AND temperature is NOT high.
(a) Write a Boolean expression for this system using the inputs T, H, M and the output W. [4]
(b) Complete the truth table for this system to show the output W. [4]
(c) Redesigning the circuit: (i) State the name of the single logic gate that produces the opposite output to an AND gate for all input combinations. [1] (ii) Explain, with reference to inputs, how a NOT gate can be constructed using only one 2-input NAND gate. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) Step-by-step translation to a Boolean expression: - "Temperature is high AND humidity is high" becomes: T AND H - "Manual override switch is ON AND temperature is NOT high" becomes: M AND NOT T - Combining these two with OR gives: W = (T AND H) OR (M AND NOT T)
(b) Truth table derivation: - Row 1 (0, 0, 0): (0 AND 0) OR (0 AND NOT 0) = 0 OR 0 = 0 - Row 2 (0, 0, 1): (0 AND 0) OR (1 AND NOT 0) = 0 OR 1 = 1 - Row 3 (0, 1, 0): (0 AND 1) OR (0 AND NOT 0) = 0 OR 0 = 0 - Row 4 (0, 1, 1): (0 AND 1) OR (1 AND NOT 0) = 0 OR 1 = 1 - Row 5 (1, 0, 0): (1 AND 0) OR (0 AND NOT 1) = 0 OR 0 = 0 - Row 6 (1, 0, 1): (1 AND 0) OR (1 AND NOT 1) = 0 OR 0 = 0 - Row 7 (1, 1, 0): (1 AND 1) OR (0 AND NOT 1) = 1 OR 0 = 1 - Row 8 (1, 1, 1): (1 AND 1) OR (1 AND NOT 1) = 1 OR 0 = 1
(c) (i) The gate that behaves as the inversion of AND is the NAND (NOT-AND) gate. (ii) A NAND gate produces an output of 1 unless both inputs are 1. By connecting both inputs together, they must always share the same value. If the input is 0, both inputs are 0, giving an output of 1. If the input is 1, both inputs are 1, giving an output of 0. This successfully mimics a NOT gate.
Marking scheme
Part (a) [Max 4 marks]: - 1 mark for: T AND H - 1 mark for: NOT T - 1 mark for: M AND NOT T - 1 mark for joining terms with OR (Accept equivalent boolean representations: W = (T . H) + (M . T') )
Part (b) [Max 4 marks]: - 4 marks for all 8 output values correct (0, 1, 0, 1, 0, 0, 1, 1) - 3 marks for 6 or 7 output values correct - 2 marks for 4 or 5 output values correct - 1 mark for 2 or 3 output values correct
Part (c) [Max 3 marks]: - (i) 1 mark for naming: NAND gate (Do not accept AND gate followed by NOT gate as it asks for a single logic gate) - (ii) 2 marks: - 1 mark for explaining that both inputs of the 2-input NAND gate must be tied/joined together (to a single input line). - 1 mark for explaining the logic (e.g., if input is 1, NAND output is 0; if input is 0, NAND output is 1).
Question 8 · structured
8.5 marks
A travel agency uses a database table named tblFlights to store information about upcoming flights. The table contains the following fields: - FlightID (e.g. 'FL102') - Destination (e.g. 'London') - DepartureTime (e.g. '14:30') - Capacity (e.g. 180) - Price (e.g. 120.50) - Delay (e.g. True/False)
(a) State which field should be used as the primary key. [1 mark]
(b) Identify the most appropriate data type for the following fields: - FlightID - DepartureTime - Capacity - Price - Delay [2.5 marks]
(c) Write an SQL query to retrieve and display the FlightID and Destination for all flights with a Price less than 150.00 and that are NOT delayed (Delay is False). Show the results sorted in ascending order of Price. [5 marks]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Part (a): FlightID is the correct primary key because it is unique for each flight record, whereas destinations, departure times, capacities, prices, and delay statuses can be repeated across different flights.
Part (b): - FlightID: Text/Alphanumeric because it contains both letters and numbers. - DepartureTime: Time (or Date/Time) to capture hours and minutes accurately. - Capacity: Integer because it represents a count of physical seats (cannot have fractions of a seat). - Price: Real / Currency / Decimal to support fractional numbers (e.g., 120.50). - Delay: Boolean because it represents binary states (True/False).
Part (c): The query must select 'FlightID' and 'Destination', filter using '< 150.00' and 'Delay = False', and sort using 'ORDER BY Price ASC' (or simply 'ORDER BY Price' as ASC is the default).
Part (c) [5 marks]: - 1 mark: SELECT FlightID, Destination - 1 mark: FROM tblFlights - 1 mark: WHERE Price < 150.00 - 1 mark: ... AND Delay = False (accept equivalent syntax like Delay = 0 or NOT Delay) - 1 mark: ORDER BY Price (ASC/ascending is optional but correct)
Question 9 · structured
8.5 marks
A school library manages its inventory using a database table named tblBooks. The table contains the following fields: - BookID (e.g. 'BK9831') - Title (e.g. 'The Great Gatsby') - Author (e.g. 'F. Scott Fitzgerald') - Genre (e.g. 'Fiction') - YearPublished (e.g. 1925) - OnLoan (e.g. True/False)
(a) Identify the field that is most suitable to be the primary key and explain why. [2.5 marks]
(b) Suggest one suitable validation check that could be performed on the YearPublished field to ensure only reasonable years (e.g. after the year 1440 and up to the current year) are entered. Explain your choice. [1 mark]
(c) Write an SQL query to display the Title and Author of all books where the Genre is either 'Science' or 'History', and that are currently NOT on loan (OnLoan is False). The output must be sorted alphabetically by the Author. [5 marks]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Part (a): BookID is the primary key. Explanation: A library might have multiple copies of the exact same book (same Title, Author, Genre, and YearPublished), meaning non-key attributes are not guaranteed to be unique. BookID uniquely identifies each unique book copy.
Part (b): A Range Check is appropriate because it verifies that the input year falls within a realistic historical and modern boundary (e.g., between 1440 and the current calendar year).
Part (c): - SELECT Title, Author - FROM tblBooks - WHERE (Genre = 'Science' OR Genre = 'History') AND OnLoan = False - ORDER BY Author ASC (Note: parentheses around the OR condition are critical so that the AND operator evaluates correctly across both genres).
Marking scheme
Part (a) [2.5 marks]: - 1 mark: BookID - 1.5 marks: Correct explanation pointing out that multiple books can share the same title, author, or publisher, meaning a custom unique identifier is required to distinguish individual items in the inventory.
Part (b) [1 mark]: - 1 mark: Range check / Limit check with correct logic defined (e.g., checking if value is >= 1440 and <= current year).
Part (c) [5 marks]: - 1 mark: SELECT Title, Author - 1 mark: FROM tblBooks - 1 mark: WHERE (Genre = 'Science' OR Genre = 'History') (Accept OR logic, but require correct parentheses context when combined with AND) - 1 mark: ... AND OnLoan = False (accept OnLoan = 0 or NOT OnLoan) - 1 mark: ORDER BY Author (ASC/ascending is optional but correct)
Question 10 · practical
15 marks
A car park has 5 floors, and each floor has 10 parking spaces. A computer system uses a 2D array named CarPark of size [1:5, 1:10] of type String to store the registration number of parked cars. Empty spaces are represented by the string 'Empty'.
Write an algorithm, using pseudocode, to meet the following requirements: - Initialize all spaces in the CarPark 2D array to 'Empty'. - Prompt the user to enter a choice: 'Park', 'Leave', 'Display', or 'Exit'. - If 'Park' is chosen: - Prompt for and input the floor number (1 to 5) and space number (1 to 10). - Validate the inputs. - If the space is 'Empty', prompt for the registration plate and store it in that space. - If the space is already occupied, display an appropriate error message. - If 'Leave' is chosen: - Prompt for and input the floor number and space number. - Validate the inputs. - If the space is occupied, set it to 'Empty' and output a success message. - If the space is already empty, display an appropriate error message. - If 'Display' is chosen: - Calculate and output the total number of empty spaces and the total number of occupied spaces in the entire car park. - The program should repeatedly prompt for a choice until the user enters 'Exit'.
Write structured pseudocode using standard Cambridge IGCSE conventions.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Here is the complete structured pseudocode solution:
// Initialize array FOR Row <- 1 TO 5 FOR Col <- 1 TO 10 CarPark[Row, Col] <- "Empty" NEXT Col NEXT Row
Choice <- "" WHILE Choice <> "Exit" DO OUTPUT "Enter choice (Park, Leave, Display, Exit): " INPUT Choice IF Choice = "Park" THEN OUTPUT "Enter floor (1-5): " INPUT Floor OUTPUT "Enter space (1-10): " INPUT Space IF Floor >= 1 AND Floor <= 5 AND Space >= 1 AND Space <= 10 THEN IF CarPark[Floor, Space] = "Empty" THEN OUTPUT "Enter registration plate: " INPUT RegPlate CarPark[Floor, Space] <- RegPlate OUTPUT "Car parked successfully." ELSE OUTPUT "Error: Space is already occupied." ENDIF ELSE OUTPUT "Error: Invalid floor or space." ENDIF ELSEIF Choice = "Leave" THEN OUTPUT "Enter floor (1-5): " INPUT Floor OUTPUT "Enter space (1-10): " INPUT Space IF Floor >= 1 AND Floor <= 5 AND Space >= 1 AND Space <= 10 THEN IF CarPark[Floor, Space] <> "Empty" THEN CarPark[Floor, Space] <- "Empty" OUTPUT "Space is now vacant." ELSE OUTPUT "Error: Space is already empty." ENDIF ELSE OUTPUT "Error: Invalid floor or space." ENDIF ELSEIF Choice = "Display" THEN EmptyCount <- 0 OccupiedCount <- 0 FOR Row <- 1 TO 5 FOR Col <- 1 TO 10 IF CarPark[Row, Col] = "Empty" THEN EmptyCount <- EmptyCount + 1 ELSE OccupiedCount <- OccupiedCount + 1 ENDIF NEXT Col NEXT Row OUTPUT "Total empty spaces: ", EmptyCount OUTPUT "Total occupied spaces: ", OccupiedCount ELSEIF Choice <> "Exit" THEN OUTPUT "Invalid choice. Please try again." ENDIF ENDWHILE
Marking scheme
Award 1 mark for each of the following (up to 15 marks total): 1. Initializing 2D array elements using nested loops. 2. Correct loop boundaries for initialization (1 to 5, and 1 to 10). 3. Setting all array elements to 'Empty'. 4. Continuous loop (WHILE ... DO or REPEAT ... UNTIL) controlled by the exit condition 'Exit'. 5. Prompting for and inputting the user choice inside the main loop. 6. Validation of inputs for Floor (1 to 5) and Space (1 to 10). 7. Checking if space is empty ('Empty') before parking. 8. Prompting and storing registration plate in correct index: CarPark[Floor, Space]. 9. Outputting error message if spot is occupied when parking. 10. Checking if space is NOT empty before freeing (for Leave choice). 11. Resetting correct coordinate in array to 'Empty' when leaving. 12. Outputting error message if spot is already empty when leaving. 13. Resetting counting variables (EmptyCount, OccupiedCount) to 0 inside 'Display' block before loops. 14. Correct nested loops and conditions to count empty and occupied spots. 15. Outputting final counts with explanatory text.
Wondering how well you actually know this?
Thinka is an AI practice app for DSE 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.