Cambridge IGCSE · thinka-original Practice Paper

2023 Cambridge IGCSE Computer Science (0478) Practice Paper with Answers

Thinka Nov 2023 (V3) Cambridge IGCSE-Style Mock — Computer Science (0478)

150 marks210 mins2023
An original Thinka practice paper modelled on the structure and difficulty of the Nov 2023 (V3) Cambridge IGCSE 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 & Recall
3 marks
Describe the role of the Program Counter (PC) during the fetch stage of the fetch-decode-execute cycle.
Show answer & marking scheme

Worked solution

1. The PC holds the memory address of the next instruction to be fetched from primary storage (RAM).
2. This memory address is copied from the PC to the Memory Address Register (MAR) using the address bus.
3. The PC is then incremented (by 1) to point to the next instruction in sequence.

Marking scheme

One mark per correct point, up to a maximum of 3 marks:
- Holds the address of the next instruction to be fetched/executed (1 mark)
- Copies/sends the address to the Memory Address Register (MAR) (1 mark)
- Increments (by 1) (to point to the next instruction) (1 mark)
Question 2 · Short Answer & Recall
3 marks
State three reasons why a computer programmer would use hexadecimal rather than binary when writing code.
Show answer & marking scheme

Worked solution

1. Hexadecimal is easier and quicker for humans to read, write, and understand compared to long strings of binary.
2. It reduces the likelihood of input or typing errors when entering values.
3. It is much easier to identify and debug errors in hexadecimal notation.

Marking scheme

One mark per correct point, up to a maximum of 3 marks:
- Easier/quicker to read, write, or understand (1 mark)
- Less prone to input/typing errors (1 mark)
- Easier to identify/debug errors (1 mark)
- Requires fewer characters/digits to represent the same value (takes up less space on screen) (1 mark)
Question 3 · Short Answer & Recall
3 marks
A student transmits a large data file across a network. A checksum is used to verify that the file is received without errors.

Describe how a checksum is used to detect errors in the received data.
Show answer & marking scheme

Worked solution

1. Before transmission, the sender calculates a checksum value using an algorithm on the data block.
2. The calculated checksum is transmitted along with the data file.
3. Upon receipt, the receiver recalculates the checksum using the same algorithm on the received data, and compares it to the transmitted checksum. If they differ, an error has occurred.

Marking scheme

One mark per correct point, up to a maximum of 3 marks:
- Sender calculates a checksum value from the data (using an algorithm/formula) (1 mark)
- Checksum value is transmitted with the data block (1 mark)
- Receiver recalculates the checksum from the received data using the same algorithm (1 mark)
- The received and recalculated checksums are compared (1 mark)
- If they do not match, an error is detected / retransmission is requested (1 mark)
Question 4 · Short Answer & Recall
3 marks
A customer visits an online shopping website. The website stores cookies on the customer's computer.

Describe how the website uses these cookies during and after the customer's visit.
Show answer & marking scheme

Worked solution

1. Cookies are small text files stored on the user's computer by their web browser.
2. They store information such as user preferences, shopping cart items, or login status.
3. When the user navigates the site or visits it again later, the browser sends the cookie back to the web server, allowing the site to recall the user's details and personalise their experience.

Marking scheme

One mark per correct point, up to a maximum of 3 marks:
- Cookies are small text files saved/stored on the user's local drive/browser (1 mark)
- They store user credentials / login status / items in a shopping cart / user tracking data (1 mark)
- The web server reads the cookie when the user requests a page / visits the site again (1 mark)
- Allows the website to customise/personalise the web page / keep the user logged in (1 mark)
Question 5 · Short Answer & Recall
3 marks
A developer is preparing a text-based document for online distribution and wants to reduce its file size. They decide to use lossless compression.

Explain why lossless compression must be used for this text document rather than lossy compression.
Show answer & marking scheme

Worked solution

1. Lossless compression allows the original file to be reconstructed exactly without any loss of data.
2. Lossy compression permanently deletes data deemed unnecessary, which is irreversible.
3. If lossy compression were used on a text document, characters, words, or formatting would be permanently lost, making the text unreadable, corrupted, or altered in meaning.

Marking scheme

One mark per correct point, up to a maximum of 3 marks:
- Lossless compression preserves all original data / is fully reversible (1 mark)
- Lossy compression permanently discards/deletes data (1 mark)
- Removing data from a text file would result in missing characters/words/formatting / make the file unreadable / corrupt the file (1 mark)
Question 6 · Explanatory
8 marks
A musician is recording a new song on their computer using a digital audio workstation (DAW).

(a) Describe how the analogue sound from the musician's guitar is converted into a digital format. [3]

(b) Explain the effects of increasing the sampling resolution on the digital audio file. [3]

(c) The musician wants to upload the track to a streaming platform. They decide to compress the file using lossy compression. Give two reasons why lossy compression is suitable for this purpose. [2]
Show answer & marking scheme

Worked solution

(a)
1. The analogue sound waves from the guitar are picked up by a microphone, which converts them into an analogue electrical signal.
2. An Analogue-to-Digital Converter (ADC) samples the amplitude of this analogue electrical signal at regular time intervals (sampling rate).
3. The amplitude of each sample is measured and converted into a binary value representing the closest approximate value, determined by the sampling resolution.

(b)
1. Increasing sampling resolution means more bits are used to represent each individual sound sample.
2. This results in a more accurate representation of the original sound amplitude, reducing quantization noise and expanding the dynamic range.
3. Consequently, the audio quality/fidelity is improved (closer to the original analogue signal), but this also increases the overall file size.

(c)
1. Lossy compression significantly reduces the file size, allowing for faster upload, download, and streaming over networks with lower bandwidth.
2. It discards frequencies and sounds that are generally imperceptible to the average human ear (perceptual coding), meaning the perceived drop in quality is minimal for standard listening.

Marking scheme

(a) One mark per correct point, up to a maximum of 3:
- The sound waves are captured by a microphone and converted into an analogue electrical signal [1]
- The analogue signal is sampled by an Analogue-to-Digital Converter (ADC) [1]
- The samples are taken at regular time intervals [1]
- The amplitude of each sample is measured / quantized [1]
- Each amplitude value is converted into a binary code [1]

(b) One mark per correct point, up to a maximum of 3:
- More bits are allocated to represent the amplitude of each sample [1]
- The representation of the sound wave becomes more accurate / reduces quantization errors [1]
- Sound quality / dynamic range / audio fidelity is improved [1]
- The overall storage file size of the audio track increases [1]

(c) One mark per correct point, up to a maximum of 2:
- Substantially reduces the file size to allow faster streaming / downloading / uploading [1]
- Reduces the bandwidth required to stream the file [1]
- The data removed / discarded consists of frequencies that cannot easily be heard by the human ear, so quality loss is negligible [1]
Question 7 · Scenario-based
8 marks
An automated smart greenhouse uses a central processing unit (CPU) based on the Von Neumann architecture to control its environmental conditions.

(a) During the fetch stage of the fetch-decode-execute cycle, certain registers are used. State the purpose of the following registers during this stage:
(i) Program Counter (PC) [1]
(ii) Memory Address Register (MAR) [1]

(b) Describe the role of the Control Unit (CU) during the decode and execute stages of the cycle. [3]

(c) The greenhouse system has a temperature sensor that can trigger an interrupt if the temperature exceeds a safe limit. Explain how the CPU processes this interrupt. [3]
Show answer & marking scheme

Worked solution

(a)
(i) Program Counter (PC): Holds the address of the next instruction that needs to be fetched from memory.
(ii) Memory Address Register (MAR): Holds the address in memory from which data or an instruction is currently being read (or to which it is being written).

(b)
During the decode stage, the Control Unit (CU) decodes the instruction held in the Instruction Register (IR/CIR) to interpret what operation must be performed. During the execute stage, the CU coordinates CPU activities by generating control signals to direct other components (such as the ALU, registers, and memory) on how to carry out the instruction.

(c)
1. The CPU receives an interrupt signal from the temperature sensor via the control bus.
2. At the end of the current fetch-decode-execute cycle, the CPU checks for interrupt signals.
3. If an interrupt is detected, the CPU halts the execution of the current program and saves the contents of its registers (including the PC) onto a stack.
4. The CPU then loads the program counter with the address of the Interrupt Service Routine (ISR) designed to handle the temperature warning.
5. Once the ISR is completed, the CPU restores the saved register states from the stack and resumes the interrupted program.

Marking scheme

(a)
(i) One mark for PC definition:
- Holds the address of the next instruction to be fetched [1]
(ii) One mark for MAR definition:
- Holds the memory address of the current instruction/data being accessed [1]

(b) One mark per correct point, up to a maximum of 3:
- CU decodes / interprets the instruction to determine what action is required [1]
- CU sends control signals to coordinate the execution of the instruction [1]
- CU directs the flow of data within the CPU [1]
- CU manages the synchronization of instructions using the system clock [1]

(c) One mark per correct point, up to a maximum of 3:
- CPU checks for interrupts at the end of every fetch-decode-execute cycle [1]
- Current CPU status / register values / PC value is saved onto a stack [1]
- CPU loads the Interrupt Service Routine (ISR) / interrupt handler program [1]
- The CPU executes the ISR to address the emergency (e.g. sound alarm, open vents) [1]
- Once handled, the saved state is restored from the stack and the main program resumes [1]
Question 8 · Scenario-based
8 marks
A user is logging into their online banking portal using a web browser to transfer money.

(a) The connection between the user's web browser and the bank's server is secured using the SSL/TLS protocol. Explain how this protocol establishes a secure connection. [4]

(b) State what the padlock icon in the browser's address bar indicates to the user about the website. [2]

(c) State two functions of a web browser other than securing connections. [2]
Show answer & marking scheme

Worked solution

(a)
1. The browser requests the server to identify itself (initiates handshake).
2. The bank's server sends its SSL/TLS certificate containing its public key.
3. The browser validates the certificate against a list of trusted Certificate Authorities (CAs) to ensure its legitimacy.
4. Once verified, the browser generates a symmetric session key, encrypts it using the server's public key, and sends it back.
5. The server decrypts the session key using its private key.
6. Both parties use the symmetric session key to encrypt and decrypt all subsequent transmitted data.

(b)
1. The padlock icon indicates that the connection is fully encrypted (using HTTPS / SSL / TLS), preventing eavesdropping or data interception.
2. It signifies that the website has a valid SSL/TLS security certificate, verifying that the user is connected to the authentic site and not a spoofed clone.

(c)
1. It renders HTML documents to display web pages correctly on screen.
2. It manages browser history, bookmarks, and user favourites for easy navigation.
3. It stores cookies to maintain user sessions or preferences.

Marking scheme

(a) One mark per correct point, up to a maximum of 4:
- The browser requests a secure connection / server identifies itself [1]
- The server sends its digital SSL/TLS certificate (which contains its public key) [1]
- The browser verifies the certificate with a trusted Certificate Authority (CA) [1]
- Once verified, the browser generates and encrypts a session key using the server's public key [1]
- The server decrypts the session key using its private key [1]
- A secure symmetric encryption channel is established for all subsequent data transmission [1]

(b) One mark per correct point, up to a maximum of 2:
- Indicates that the connection is encrypted / secure / uses HTTPS [1]
- Indicates that the website's identity has been verified / is authentic / has a valid security certificate [1]
- Confirms that data cannot be read in transit by third parties [1]

(c) One mark per correct point, up to a maximum of 2:
- Renders / interprets HTML (and CSS/JS) to display web pages [1]
- Allows the user to store and manage bookmarks / favourites [1]
- Keeps a history of visited web pages [1]
- Manages and stores cookies [1]
- Provides navigation tools (back, forward, refresh buttons) [1]
Question 9 · Data Conversion & Arithmetic
13 marks
Computers store and process data using different number systems and representations.

(a) (i) Convert the denary number 109 into 8-bit binary. Show your working.

(ii) Convert your binary answer from part (a)(i) into hexadecimal. Show your working.

(b) Convert the negative denary number \(-43\) into 8-bit binary using two's complement. Show all your working.

(c) (i) Add the binary values 10011011 and 01110010 using binary addition. Give your answer in binary. Show all your working including any carries.

(ii) State whether an overflow error occurs during the addition in part (c)(i). Explain your answer.

(d) (i) Perform a logical right shift of two places on the binary pattern 11001000.

(ii) Describe the effect of this shift on the denary value represented by the binary pattern.
Show answer & marking scheme

Worked solution

(a) (i)
- Binary calculation:
\(109 = 64 + 32 + 8 + 4 + 1\)
- Corresponding binary pattern:
\(128\ |\ 64\ |\ 32\ |\ 16\ |\ 8\ |\ 4\ |\ 2\ |\ 1\)
\(0\ |\ 1\ |\ 1\ |\ 0\ |\ 1\ |\ 1\ |\ 0\ |\ 1\)
- Result: 01101101

(a) (ii)
- Split binary 01101101 into two 4-bit nibbles: 0110 and 1101
- \(0110_2 = 6_{10} = 6_{16}\)
- \(1101_2 = 13_{10} = \text{D}_{16}\)
- Hexadecimal result: 6D

(b)
- Represent positive 43 in 8-bit binary: 00101011
- Invert all bits (one's complement): 11010100
- Add 1 (two's complement): 11010101
- Alternatively: \(-128 + 64 + 16 + 4 + 1 = -43\), giving 11010101

(c) (i)
```
1 1 1 1 1 (carries)
10011011
+ 01110010
------------
100001101
```
- The 8-bit result is 00001101 (with a ninth overflow carry bit of 1).

(c) (ii)
- Yes, an overflow error occurs.
- Reason: The sum of the two numbers is 269 (\(155 + 114\)), which is greater than the maximum value representable in an unsigned 8-bit register (255). A ninth bit is generated during the addition.

(d) (i)
- Shifting 11001000 right by two places moves all bits two places to the right and pads the left with zeros:
- Result: 00110010

(d) (ii)
- The logical right shift of two places divides the denary value by 4.

Marking scheme

(a) (i) Max 2 marks:
- 1 mark for showing correct working (e.g. division by 2, or correct place value columns: \(64 + 32 + 8 + 4 + 1\))
- 1 mark for correct final binary answer: 01101101

(a) (ii) Max 2 marks:
- 1 mark for showing correct method (e.g. splitting binary into 4-bit nibbles or dividing 109 by 16)
- 1 mark for correct hexadecimal answer: 6D (Accept 6d)

(b) Max 3 marks:
- 1 mark for binary representation of positive 43 (00101011) OR correct column values with negative sign shown
- 1 mark for inverting bits (11010100) OR adding 1
- 1 mark for correct 8-bit binary answer: 11010101

(c) (i) Max 2 marks:
- 1 mark for showing correct working with at least three carry bits visible above the columns
- 1 mark for correct binary sum: 00001101 (Accept 100001101)

(c) (ii) Max 2 marks:
- 1 mark for stating that an overflow error does occur
- 1 mark for valid reason (e.g. the 8-bit register cannot hold the 9-bit result / the result exceeds 255 / the denary total is 269 which is outside the range)

(d) (i) Max 1 mark:
- 1 mark for correct binary shift result: 00110010

(d) (ii) Max 1 mark:
- 1 mark for stating the value is divided by 4 (Accept: divided by 2 twice)
Question 10 · Diagram Design
4 marks
Draw and annotate a diagram to represent the role of a firewall.
Show answer & marking scheme

Worked solution

A complete diagram must illustrate the firewall acting as a barrier between two environments (typically a private/internal network and the public internet).

**Visual Elements to Include:**
- **Internal Network / Private Computer**: Labeled on one side.
- **Firewall**: Labeled as a barrier/wall in the middle.
- **External Network / Internet**: Labeled on the opposite side.
- **Data Packets / Traffic Arrows**: Showing movement towards the internal network from the internet.

**Annotations/Key Features:**
1. **Boundary Position**: Clearly label that the firewall sits between the trusted internal network and the untrusted external internet.
2. **Packet Inspection**: Labeled arrow or box indicating that the firewall examines the packet headers, IP addresses, or ports against a pre-defined set of rules (criteria).
3. **Permitted Traffic**: Show an arrow representing 'safe' traffic passing through the firewall to the internal network.
4. **Blocked Traffic**: Show an arrow representing 'malicious' or unauthorized traffic being stopped, dropped, or rejected at the firewall boundary.

Marking scheme

Award 1 mark for each of the following points, up to a maximum of 4 marks:

- **Positioning**: Drawing a firewall positioned on the boundary between a trusted/private network (or device) and an untrusted/public network (e.g., the Internet).
- **Flow of Traffic**: Drawing arrows/packets showing incoming and/or outgoing data traffic traversing toward the firewall.
- **Rule Comparison / Inspection**: Labeled annotation explaining that incoming packets are inspected and checked against a criteria list / security rules (e.g., IP address, port number, packet content).
- **Permitting Safe Traffic**: Labeled representation or arrow showing authorized/safe traffic successfully passing through the firewall.
- **Blocking Malicious Traffic**: Labeled representation or arrow showing unauthorized/malicious traffic being blocked, redirected, or dropped by the firewall.
Question 11 · Diagram Design
4 marks
Draw and annotate a diagram to represent the role of a firewall.
Show answer & marking scheme

Worked solution

A complete diagram must illustrate the firewall acting as a barrier between two environments (typically a private/internal network and the public internet).

**Visual Elements to Include:**
- **Internal Network / Private Computer**: Labeled on one side.
- **Firewall**: Labeled as a barrier/wall in the middle.
- **External Network / Internet**: Labeled on the opposite side.
- **Data Packets / Traffic Arrows**: Showing movement towards the internal network from the internet.

**Annotations/Key Features:**
1. **Boundary Position**: Clearly label that the firewall sits between the trusted internal network and the untrusted external internet.
2. **Packet Inspection**: Labeled arrow or box indicating that the firewall examines the packet headers, IP addresses, or ports against a pre-defined set of rules (criteria).
3. **Permitted Traffic**: Show an arrow representing 'safe' traffic passing through the firewall to the internal network.
4. **Blocked Traffic**: Show an arrow representing 'malicious' or unauthorized traffic being stopped, dropped, or rejected at the firewall boundary.

Marking scheme

Award 1 mark for each of the following points, up to a maximum of 4 marks:

- **Positioning**: Drawing a firewall positioned on the boundary between a trusted/private network (or device) and an untrusted/public network (e.g., the Internet).
- **Flow of Traffic**: Drawing arrows/packets showing incoming and/or outgoing data traffic traversing toward the firewall.
- **Rule Comparison / Inspection**: Labeled annotation explaining that incoming packets are inspected and checked against a criteria list / security rules (e.g., IP address, port number, packet content).
- **Permitting Safe Traffic**: Labeled representation or arrow showing authorized/safe traffic successfully passing through the firewall.
- **Blocking Malicious Traffic**: Labeled representation or arrow showing unauthorized/malicious traffic being blocked, redirected, or dropped by the firewall.

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 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 · Single Choice Selection
1 marks
An algorithm only accepts integer values from 10 to 50 inclusive.

Select the option that shows a correct set of boundary test data for this algorithm.

A) 10, 30, 50
B) 9, 10, 50, 51
C) 8, 11, 49, 52
D) 0, 10, 50, 100
Show answer & marking scheme

Worked solution

Boundary data consists of the values at the extreme limits of the acceptable range (10 and 50) and the immediate values outside those limits (9 and 51). Therefore, 9, 10, 50, and 51 represent a correct set of boundary test data.

Marking scheme

1 mark for the correct selection of option B. Reject any other option.
Question 2 · Single Choice Selection
1 marks
Identify the logic gate that matches the following description:

"The output is 1 if at least one input is 0."

A) NOR
B) XOR
C) NAND
D) OR
Show answer & marking scheme

Worked solution

A NAND gate outputs 1 in all cases except when both inputs are 1. This means it outputs 1 if at least one input is 0. Thus, NAND is the correct answer.

Marking scheme

1 mark for the correct selection of option C. Reject any other option.
Question 3 · Structured Pseudocode & Tracing
7 marks
An algorithm is required to process student exam marks. The algorithm must:
- Input marks one by one.
- A value of -1 must be used to stop the inputs.
- Count how many valid marks (marks between 0 and 100 inclusive) were entered.
- Calculate and output the average of these valid marks.
- If no valid marks were entered, output 'Error: No valid marks'.

(a) Write a pseudocode algorithm that meets these requirements. [5]
(b) State the type of loop structure used in your algorithm to control inputs, and explain why this type of loop is appropriate. [2]
Show answer & marking scheme

Worked solution

(a) Pseudocode implementation:
```pseudocode
DECLARE Mark, Total, Count : INTEGER
DECLARE Average : REAL
Total <-- 0
Count <-- 0
OUTPUT "Enter a mark (-1 to stop): "
INPUT Mark
WHILE Mark <> -1 DO
IF Mark >= 0 AND Mark <= 100 THEN
Total <-- Total + Mark
Count <-- Count + 1
ENDIF
OUTPUT "Enter next mark (-1 to stop): "
INPUT Mark
ENDWHILE

IF Count > 0 THEN
Average <-- Total / Count
OUTPUT "The average mark is ", Average
OUTPUT "Number of valid marks: ", Count
ELSE
OUTPUT "Error: No valid marks"
ENDIF
```

(b)
- Loop type: Conditional loop / pre-condition loop (WHILE ... DO ... ENDWHILE).
- Explanation: A conditional loop is used because the exact number of marks to be entered is not known in advance; the loop must continue executing until a sentinel value (-1) is entered.

Marking scheme

Part (a) [Max 5 marks]:
- 1 mark: Initialising variables (Total, Count) to 0.
- 1 mark: Correct input of sentinel variable before/within the loop.
- 1 mark: Correct loop condition matching the termination value (e.g. Mark <> -1).
- 1 mark: Correct conditional validation checks (Mark >= 0 AND Mark <= 100) inside the loop.
- 1 mark: Correct accumulation of Total and incrementing Count.
- 1 mark: Correct check (Count > 0) to avoid division by zero before calculating the average, with suitable output messages.

Part (b) [2 marks]:
- 1 mark: Correctly identifying the loop type (conditional loop, pre-condition loop, or WHILE loop).
- 1 mark: Providing a matching reason (e.g. the number of inputs/iterations is unknown beforehand).
Question 4 · Structured Pseudocode & Tracing
7 marks
The 1D array DataList contains the following six integers:
DataList[1] = 15, DataList[2] = 9, DataList[3] = 22, DataList[4] = 6, DataList[5] = 11, DataList[6] = 18

Consider the following pseudocode algorithm:
```pseudocode
DECLARE Index, Temp, Swaps OF INTEGER
Swaps <-- 0
FOR Index <-- 1 TO 5
IF DataList[Index] > DataList[Index + 1] THEN
Temp <-- DataList[Index]
DataList[Index] <-- DataList[Index + 1]
DataList[Index + 1] <-- Temp
Swaps <-- Swaps + 1
ENDIF
NEXT Index
OUTPUT Swaps
```

(a) Complete the trace table below for this algorithm. [5]

| Index | Temp | Swaps | DataList[1] | DataList[2] | DataList[3] | DataList[4] | DataList[5] | DataList[6] | OUTPUT |
|---|---|---|---|---|---|---|---|---|---|
| | | 0 | 15 | 9 | 22 | 6 | 11 | 18 | |
| | | | | | | | | | |

(b) Describe what this algorithm achieves in relation to the array DataList. [2]
Show answer & marking scheme

Worked solution

(a) Completed trace table:

| Index | Temp | Swaps | DataList[1] | DataList[2] | DataList[3] | DataList[4] | DataList[5] | DataList[6] | OUTPUT |
|---|---|---|---|---|---|---|---|---|---|
| | | 0 | 15 | 9 | 22 | 6 | 11 | 18 | |
| 1 | 15 | 1 | 9 | 15 | | | | | |
| 2 | | | | | | | | | |
| 3 | 22 | 2 | | | 6 | 22 | | | |
| 4 | 22 | 3 | | | | 11 | 22 | | |
| 5 | 22 | 4 | | | | | 18 | 22 | |
| | | | | | | | | | 4 |

(Note: Empty cells indicate that there was no change to the variable/element in that step).

(b)
- The algorithm performs one complete pass of a bubble sort.
- It bubbles/moves the largest element (22) to its correct sorted position at the end of the array (DataList[6]) and returns the count of swap operations performed.

Marking scheme

Part (a) [5 marks]:
- 1 mark: Correct Index values entered in sequence (1, 2, 3, 4, 5).
- 1 mark: Swaps column updated correctly (1, 2, 3, 4).
- 1 mark: Temp column updated with correctly swapped values (15, 22, 22, 22).
- 1 mark: Array elements in DataList updated correctly in sequence across rows.
- 1 mark: Final output column displays the value 4.

Part (b) [2 marks]:
- 1 mark: Identifies that it performs one pass of a bubble sort (or compares adjacent values and swaps them if out of order).
- 1 mark: Identifies that it moves the largest value (22) to the end of the array.
Question 5 · Structured Pseudocode & Tracing
7 marks
A system stores a list of customer names in a text file named "Customers.txt". A programmer needs to write an algorithm to read all names from "Customers.txt" and write any name that contains more than 10 characters into a separate, new text file called "LongNames.txt".

Write a pseudocode algorithm to accomplish this task. [7]
Show answer & marking scheme

Worked solution

Structured pseudocode solution:
```pseudocode
DECLARE CustomerName : STRING
OPEN "Customers.txt" FOR READ
OPEN "LongNames.txt" FOR WRITE

WHILE NOT EOF("Customers.txt") DO
READFILE "Customers.txt", CustomerName
IF LENGTH(CustomerName) > 10 THEN
WRITEFILE "LongNames.txt", CustomerName
ENDIF
ENDWHILE

CLOSE "Customers.txt"
CLOSE "LongNames.txt"
```

Marking scheme

Award marks up to a maximum of 7:
- 1 mark: Correctly opening "Customers.txt" in READ mode.
- 1 mark: Correctly opening "LongNames.txt" in WRITE/APPEND mode.
- 1 mark: Correct conditional loop checking for the end of "Customers.txt" (e.g. WHILE NOT EOF).
- 1 mark: Correct read instruction matching the opened file name.
- 1 mark: Using string length method/function correctly (e.g. LENGTH() or LEN() > 10).
- 1 mark: Correctly writing matched names into "LongNames.txt".
- 1 mark: Closing both files correctly at the end of the program.
Question 6 · Structured Pseudocode & Tracing
7 marks
A ticketing system for an art exhibition is being developed. It requires the user to input the following details:
- Visitor Age: must be a whole number between 3 and 100 inclusive.
- Ticket Category: must be either 'S' (Standard), 'C' (Concession), or 'G' (Group).

(a) Identify and explain two different validation checks that can be applied to the Visitor Age input. [4]

(b) Write a pseudocode routine that inputs the Ticket Category and validates it, repeating the input prompt until a valid category code ('S', 'C', or 'G') is entered. [3]
Show answer & marking scheme

Worked solution

(a)
1. Range check: Verifies that the entered Visitor Age is within the boundaries of 3 and 100 inclusive (e.g., Age >= 3 AND Age <= 100).
2. Type check: Ensures that the input is a whole number / integer, rejecting non-numeric inputs or decimal values.

(b) Pseudocode validation loop:
```pseudocode
DECLARE Category : CHAR
REPEAT
OUTPUT "Enter Ticket Category (S, C, or G): "
INPUT Category
IF Category <> 'S' AND Category <> 'C' AND Category <> 'G' THEN
OUTPUT "Invalid category. Please try again."
ENDIF
UNTIL Category = 'S' OR Category = 'C' OR Category = 'G'
```

Marking scheme

Part (a) [4 marks]:
- 1 mark: Identifies 'Range check'.
- 1 mark: Explains range check matching the context (checking that the input value is between 3 and 100 inclusive).
- 1 mark: Identifies another valid check (e.g. 'Type check' or 'Presence check').
- 1 mark: Explains the second check matching the context (e.g. Type check ensures only integer input; Presence check ensures the field is not left empty).

Part (b) [3 marks]:
- 1 mark: Correct use of a loop structure (e.g. REPEAT...UNTIL or WHILE...DO with initial input).
- 1 mark: Correct input mechanism inside the loop.
- 1 mark: Correct loop termination condition to validate 'S', 'C', or 'G'.
Question 7 · Logic Circuit Layout
11 marks
An automated watering system has three sensors: Moisture low (M = 1 if low, 0 if normal), Daytime (D = 1 if daytime, 0 if night), Reservoir empty (R = 1 if empty, 0 if contains water). The system turns on the sprinkler (S = 1) under either of the following conditions: - Moisture is low AND it is night (NOT daytime); - Moisture is low AND the reservoir is NOT empty. (a) Write a logic expression for this system using the inputs M, D, R and output S. [3] (b) Draw a logic circuit for the following logic expression: X = (NOT A OR B) AND (A XOR NOT C). Each logic gate must have a maximum of two inputs. [5] (c) Complete the truth table values for output X for the eight possible input combinations of A, B, and C. [3]
Show answer & marking scheme

Worked solution

(a) S = (M AND NOT D) OR (M AND NOT R). (b) The logic circuit contains 5 gates in total: - A NOT gate with input A (producing NOT A). - An OR gate with inputs NOT A and B (producing NOT A OR B). - A NOT gate with input C (producing NOT C). - An XOR gate with inputs A and NOT C (producing A XOR NOT C). - An AND gate combining the outputs of the OR and XOR gates to produce output X. (c) Calculating outputs row-by-row: Row 1 (0,0,0): (NOT 0 OR 0) AND (0 XOR NOT 0) = (1 OR 0) AND (0 XOR 1) = 1 AND 1 = 1. Row 2 (0,0,1): (1 OR 0) AND (0 XOR 0) = 1 AND 0 = 0. Row 3 (0,1,0): (1 OR 1) AND (0 XOR 1) = 1 AND 1 = 1. Row 4 (0,1,1): (1 OR 1) AND (0 XOR 0) = 1 AND 0 = 0. Row 5 (1,0,0): (0 OR 0) AND (1 XOR 1) = 0 AND 0 = 0. Row 6 (1,0,1): (0 OR 0) AND (1 XOR 0) = 0 AND 1 = 0. Row 7 (1,1,0): (0 OR 1) AND (1 XOR 1) = 1 AND 0 = 0. Row 8 (1,1,1): (0 OR 1) AND (1 XOR 0) = 1 AND 1 = 1.

Marking scheme

Part (a): [3 marks] - 1 mark for (M AND NOT D) - 1 mark for (M AND NOT R) - 1 mark for combining BOTH components with an OR operator. (Accept equivalent notation/symbols like boolean algebra). Part (b): [5 marks] - 1 mark for NOT gate on input A - 1 mark for OR gate with inputs NOT A and B - 1 mark for NOT gate on input C - 1 mark for XOR gate with inputs A and NOT C - 1 mark for AND gate connecting the outputs of the OR and XOR gates to X. Part (c): [3 marks] - 3 marks for all 8 correct outputs (1, 0, 1, 0, 0, 0, 0, 1) - 2 marks for 5 to 7 correct outputs - 1 mark for 3 to 4 correct outputs.
Question 8 · Database Queries & SQL Schema
8.5 marks
A local library uses a database table called `BookInventory` to keep track of its books. A portion of the table is shown below:

| BookID | Title | Author | Genre | YearPublished | Available | Price |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| BK-0102 | The Great Escape | Harrison, J. | Fiction | 2018 | Yes | 9.99 |
| BK-0491 | History of Computing | Smith, A. | Non-Fiction | 2021 | No | 24.50 |
| BK-0883 | Space Frontiers | Harrison, J. | Sci-Fi | 2019 | Yes | 14.99 |
| BK-0219 | Silent Horizon | Vance, L. | Fiction | 2015 | Yes | 7.99 |
| BK-1104 | Advanced Algorithms | Chen, X. | Non-Fiction | 2022 | Yes | 45.00 |
| BK-0562 | Digital Age | Smith, A. | Non-Fiction | 2020 | Yes | 18.99 |

(a) State the number of records and fields shown in this part of the database table. [2]
(b) (i) Identify a field that is suitable to be used as a primary key. [1]
(ii) Explain why this field is suitable to be used as a primary key. [1]
(c) Write the output that would be returned by the following SQL statement:
`SELECT Title, Price FROM BookInventory WHERE YearPublished >= 2020 AND Available = 'Yes';` [2.5]
(d) Complete the SQL statement to display the Title and Author of all books where the Genre is 'Fiction' and the Price is less than 10.00.
`SELECT` ....................................................................................................................................
`FROM` ........................................................................................................................................
`WHERE` ......................................................................................................................................
Show answer & marking scheme

Worked solution

(a) Records: 6, Fields: 7
(b) (i) BookID
(ii) BookID contains unique values for each record and avoids any potential duplication.
(c)
Title, Price
Advanced Algorithms, 45.00
Digital Age, 18.99
(d)
SELECT Title, Author
FROM BookInventory
WHERE Genre = 'Fiction' AND Price < 10.00;

Marking scheme

(a) 1 mark for 6 records. 1 mark for 7 fields.
(b) (i) 1 mark for BookID.
(ii) 1 mark for explaining that it contains unique data or prevents duplicate entries.
(c) 0.5 marks for correct columns (Title, Price).
1 mark for each correct row (Advanced Algorithms, 45.00 and Digital Age, 18.99).
(d) 1 mark for: SELECT Title, Author FROM BookInventory
1 mark for: WHERE Genre = 'Fiction' AND Price < 10.00
Question 9 · Database Queries & SQL Schema
8.5 marks
A car rental agency uses a database table called `CarRental` to store details of its active fleet. A portion of this table is shown below:

| LicensePlate | Brand | Model | Category | DailyRate | ActiveRental | LastServiceDate |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| AB12 CDE | Toyota | Corolla | Sedan | 35.00 | Yes | 15/03/2023 |
| XY98 ZUT | Ford | Focus | Hatchback | 30.00 | No | 10/01/2023 |
| LM45 KJH | Tesla | Model 3 | Electric | 75.00 | Yes | 22/04/2023 |
| RE67 WYM | BMW | 3 Series | Sedan | 60.00 | No | 05/02/2023 |
| QP34 PLK | Nissan | Leaf | Electric | 40.00 | No | 18/05/2023 |
| TR89 VBN | Ford | Mustang | Sport | 90.00 | Yes | 01/04/2023 |

(a) State the number of records and fields shown in this part of the database table. [2]
(b) (i) Identify a field that is suitable to be used as a primary key. [1]
(ii) Explain why the Brand field would not be suitable to be used as a primary key. [1]
(c) Write the output that would be returned by the following SQL statement:
`SELECT Model, DailyRate FROM CarRental WHERE Category = 'Sedan' AND DailyRate > 40.00;` [2.5]
(d) Complete the SQL statement to display the Brand and Category of all cars where the ActiveRental is 'Yes' and the DailyRate is less than 80.00.
`SELECT` ....................................................................................................................................
`FROM` ........................................................................................................................................
`WHERE` ......................................................................................................................................
Show answer & marking scheme

Worked solution

(a) Records: 6, Fields: 7
(b) (i) LicensePlate
(ii) The Brand field can contain duplicate values (e.g., Ford appears twice in the sample) and is therefore not unique.
(c)
Model, DailyRate
3 Series, 60.00
(d)
SELECT Brand, Category
FROM CarRental
WHERE ActiveRental = 'Yes' AND DailyRate < 80.00;

Marking scheme

(a) 1 mark for 6 records. 1 mark for 7 fields.
(b) (i) 1 mark for LicensePlate.
(ii) 1 mark for stating that brands can contain duplicates / are not unique.
(c) 0.5 marks for correct columns (Model, DailyRate).
2 marks for correct row (3 Series, 60.00).
(d) 1 mark for: SELECT Brand, Category FROM CarRental
1 mark for: WHERE ActiveRental = 'Yes' AND DailyRate < 80.00
Question 10 · subjective
15 marks
A department store tracks daily sales for 6 departments over a 7-day week. These sales figures are stored in a two-dimensional (2D) array WeeklySales[].

There are seven rows (representing each day of the week, from Monday to Sunday) and six columns (representing each department: Clothing, Electronics, Home, Food, Toys, and Beauty). For example, WeeklySales[1, 1] contains Monday's sales for Clothing, and WeeklySales[7, 6] contains Sunday's sales for Beauty.

The variables MaxDept, MinDept and TotalDept are used to store the maximum daily sales, minimum daily sales, and total weekly sales for a single department. The variables MaxStore, MaxDay and MaxDeptName are used to store the highest single-day sales figure recorded anywhere in the store, the day of the week it occurred, and the department name. The variable StoreTotal is used to store the total sales of the entire store for the week.

The array has already been set up and the data stored.

Write a program that meets the following requirements:
- finds the maximum and minimum daily sales for each department
- calculates the total sales for each department for the week
- outputs for each department:
* the name of the department (using a selection structure to determine the name based on the column index: 1 = Clothing, 2 = Electronics, 3 = Home, 4 = Food, 5 = Toys, 6 = Beauty)
* the maximum daily sales
* the minimum daily sales
* the total weekly sales
- finds the highest single-day sales value across the entire store for the week, including the day name (Monday to Sunday) and the department name where it occurred
- calculates the total sales for the entire store for the week
- outputs:
* the highest daily sales value for the week, along with the day it occurred and the department name
* the total weekly sales for the entire store

All currency values output must be formatted to two decimal places (e.g. using a rounding function like ROUND(Value, 2)) and preceded by "$".

You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.
You do not need to declare any arrays or variables; you may assume that this has already been done.
You do not need to initialise the data in the array WeeklySales[].
Show answer & marking scheme

Worked solution

// Initialize overall store variables
MaxStore <- -1.0
MaxDay <- ""
MaxDeptName <- ""
StoreTotal <- 0.0

// Loop through each of the 6 departments (columns)
FOR DeptCounter <- 1 TO 6
// Initialize department-specific variables
MaxDept <- -1.0
MinDept <- 9999999.0
TotalDept <- 0.0

// Loop through each of the 7 days of the week (rows)
FOR DayCounter <- 1 TO 7
CurrentSales <- WeeklySales[DayCounter, DeptCounter]

// Add current day's sales to department total
TotalDept <- TotalDept + CurrentSales

// Check for new department maximum
IF CurrentSales > MaxDept THEN
MaxDept <- CurrentSales
ENDIF

// Check for new department minimum
IF CurrentSales < MinDept THEN
MinDept <- CurrentSales
ENDIF

// Check if current day's sales is the highest in the entire store
IF CurrentSales > MaxStore THEN
MaxStore <- CurrentSales

// Determine day name for output
CASE OF DayCounter
1 : TempDay <- "Monday"
2 : TempDay <- "Tuesday"
3 : TempDay <- "Wednesday"
4 : TempDay <- "Thursday"
5 : TempDay <- "Friday"
6 : TempDay <- "Saturday"
7 : TempDay <- "Sunday"
ENDCASE
MaxDay <- TempDay

// Determine department name for output
CASE OF DeptCounter
1 : TempDept <- "Clothing"
2 : TempDept <- "Electronics"
3 : TempDept <- "Home"
4 : TempDept <- "Food"
5 : TempDept <- "Toys"
6 : TempDept <- "Beauty"
ENDCASE
MaxDeptName <- TempDept
ENDIF
NEXT DayCounter

// Add department total to the overall store weekly total
StoreTotal <- StoreTotal + TotalDept

// Determine department name for the current department loop
CASE OF DeptCounter
1 : DeptName <- "Clothing"
2 : DeptName <- "Electronics"
3 : DeptName <- "Home"
4 : DeptName <- "Food"
5 : DeptName <- "Toys"
6 : DeptName <- "Beauty"
ENDCASE

// Output department-specific results
OUTPUT "Department: ", DeptName
OUTPUT "Maximum Daily Sales: $", ROUND(MaxDept, 2)
OUTPUT "Minimum Daily Sales: $", ROUND(MinDept, 2)
OUTPUT "Total Weekly Sales: $", ROUND(TotalDept, 2)
OUTPUT ""
NEXT DeptCounter

// Output overall store results
OUTPUT "Total Weekly Sales for the Entire Store: $", ROUND(StoreTotal, 2)
OUTPUT "Highest Single-Day Store Sales: $", ROUND(MaxStore, 2), " (Department: ", MaxDeptName, ", Day: ", MaxDay, ")"

Marking scheme

AO2 (Apply): Maximum 9 marks
- R1 (Department-level statistics): Max 3 marks
* 1 mark: Correct nested loops structure iterating through both dimensions of the 2D array (WeeklySales[Day, Dept]).
* 1 mark: Correctly finding maximum and minimum daily sales for each department (initialized inside the outer loop).
* 1 mark: Correctly calculating running weekly totals for each department.
- R2 (Store-level statistics): Max 3 marks
* 1 mark: Correctly calculating overall store total sales by summing department totals.
* 1 mark: Correctly identifying the overall highest single-day sales across the entire store.
* 1 mark: Correctly storing and mapping the corresponding day index and department index to their text names.
- R3 (Outputs & Formatting): Max 3 marks
* 1 mark: Outputting results for each department including its correct text name mapped from the index.
* 1 mark: Outputting overall store statistics with meaningful descriptive labels.
* 1 mark: All output values rounded to two decimal places (using ROUND) and preceded by "$".

AO3 (Solution design): Maximum 6 marks
- 5-6 marks: The program is fully commented with relevant, helpful explanations. All identifiers (variables) have highly meaningful, descriptive names. The solution is in a logical order and contains no errors in control structures or array indices.
- 3-4 marks: The program contains some relevant comments. Most identifiers have meaningful names. The solution contains minor logical errors or is slightly out of order but achieves most requirements.
- 1-2 marks: The program is mostly uncommented or contains vague comments. Identifiers are basic or poorly chosen. The solution contains multiple syntax/logical errors but attempts at least one key requirement.

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