Cambridge IGCSE · thinka-original Practice Paper

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

Thinka Jun 2026 (V1) Cambridge IGCSE-Style Mock — Computer Science (0478)

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

Paper 1: Computer Systems (Theory)

Answer all questions. Calculators must not be used. Write in dark blue or black pen.
8 Question · 75 marks
Question 1 · short_answer
6 marks
A microcontroller in an automated irrigation unit stores sensor readings as 8-bit binary integers.

(a) Convert the denary number 183 into an 8-bit binary number. [1]

(b) Convert the binary number obtained in part (a) into hexadecimal. [1]

(c) The microcontroller performs a logical shift on the 8-bit register containing the binary value:
0 0 1 1 0 1 0 0

(i) State the resulting 8-bit binary value after applying a logical right shift of 2 places. [1]
(ii) State the mathematical effect of performing a logical right shift of 2 places on this value. [1]

(d) Negative values in the irrigation unit represent temperature readings below zero degrees Celsius and are stored using two's complement in an 8-bit register.

Write the two's complement 8-bit binary representation for -43. Show your working. [2]
Show answer & marking scheme

Worked solution

(a) Convert 183 to binary:
183 = 128 + 32 + 16 + 4 + 2 + 1 = 10110111

(b) Convert 10110111 to hexadecimal:
Split into two 4-bit nibbles:
1011 = 11 (denary) = B (hex)
0111 = 7 (denary) = 7 (hex)
Hexadecimal = B7

(c) (i) Shift 00110100 right by 2 places:
Bits shifted right by 2, filled with 0s on the left: 00001101
(ii) A logical right shift of 2 places divides the denary value by \(2^2 = 4\) (integer division).

(d) Two's complement representation of -43:
1. Positive 43 in 8-bit binary: 00101011
2. Invert all bits (one's complement): 11010100
3. Add 1: 11010100 + 1 = 11010101

Marking scheme

(a) 1 mark for correct 8-bit binary:
• 10110111

(b) 1 mark for correct hexadecimal representation:
• B7

(c)(i) 1 mark for correct binary pattern:
• 00001101

(c)(ii) 1 mark for:
• Divides by 4 // integer division by 4 // divides by \(2^2\)

(d) 2 marks total:
• 1 mark for showing method/working (e.g., correct 8-bit binary for +43 as 00101011 and inverting bits to 11010100, or using place value column weights -128 + 64 + 16 + 4 + 1)
• 1 mark for correct final 8-bit binary answer: 11010101
Question 2 · short_answer
6 marks
A computer system uses an 8-bit register for binary arithmetic.

(a) Add the following two 8-bit positive binary integers. Show your working and give your final answer as an 8-bit binary number.

0 1 0 1 1 1 0 0
+ 0 0 1 1 0 1 1 0
-----------------
[2]

(b) Another addition is carried out in the same 8-bit register:

1 1 0 0 1 0 0 0
+ 0 1 1 0 0 1 0 1
-----------------

(i) Calculate the result of this addition. [1]
(ii) State the term used to describe the error that occurs when storing this result in an 8-bit register. [1]
(iii) Explain why this error has occurred. [1]

(c) Hexadecimal numbers are often used by programmers to represent binary values.

Give one reason why programmers use hexadecimal instead of binary. [1]
Show answer & marking scheme

Worked solution

(a) Perform binary addition:
01011100 (92)
+ 00110110 (54)
Carries: 1111000
Result: 10010010 (146 in denary)

(b) (i) Perform binary addition:
11001000 (200)
+ 01100101 (101)
Carries: 10000000
Result: 100101101 (9-bit result: 301 in denary) or 00101101 with carry 1.
(ii) Overflow error
(iii) An 8-bit unsigned register can only store values up to 255 (
\(2^8 - 1\)). The sum is 301 (or 9 bits), so the most significant bit is lost / there is a carry bit that cannot fit in the 8-bit register.

(c) Hexadecimal is shorter / more compact than binary, easier to read/write/debug, and reduces the risk of input error by programmers.

Marking scheme

(a) 2 marks total:
• 1 mark for correct carry bits / clear addition method
• 1 mark for correct 8-bit binary answer: 10010010

(b)(i) 1 mark for correct 9-bit sum / result:
• 100101101 // (1) 00101101

(b)(ii) 1 mark for:
• Overflow (error)

(b)(iii) 1 mark for:
• The result is greater than 255 // the result requires 9 bits to store // cannot fit in an 8-bit register // carry bit generated out of MSB

(c) 1 mark for any one valid reason:
• Shorter / more compact representation // uses fewer digits
• Easier for humans to read / write / understand
• Easier to debug / identify errors
• Reduces human transcription/input errors
(Note: Do NOT accept 'takes up less computer memory' / 'faster for computer to process' - TV)
Question 3 · structured
11 marks
A computer uses the Von Neumann architecture.

(a) The Central Processing Unit (CPU) contains dedicated registers and system buses.

(i) State the role of the Memory Address Register (MAR). [1]

(ii) State the role of the Current Instruction Register (CIR). [1]

(iii) Identify the system bus used to transfer memory addresses, and state its directionality (unidirectional or bidirectional). [2]

(b) Describe the sequence of events that takes place during the fetch stage of the Fetch–Decode–Execute (FDE) cycle. [4]

(c) A computer user replaces their existing CPU with a new processor that has a higher clock speed and a larger cache size.

Explain how both a higher clock speed and a larger cache size improve the performance of the CPU. [3]
Show answer & marking scheme

Worked solution

(a)(i) The Memory Address Register (MAR) holds the memory address of the location in main memory (RAM) that is currently being accessed for a read or write operation.

(ii) The Current Instruction Register (CIR) holds the instruction that was fetched from memory while it is being decoded and executed.

(iii) System bus: Address bus.
Directionality: Unidirectional (data/addresses only travel in one direction, from the CPU/processor to memory/I/O).

(b) Sequence during the fetch stage:
1. The address of the next instruction to be fetched is copied from the Program Counter (PC) to the Memory Address Register (MAR) via the address bus.
2. A read signal is sent across the control bus to memory.
3. The instruction located at that address in main memory (RAM) is copied via the data bus into the Memory Data Register (MDR) // Memory Buffer Register (MBR).
4. The Program Counter (PC) is incremented by 1 to point to the address of the next instruction.
5. The instruction in the MDR is copied to the Current Instruction Register (CIR).

(c) How performance is improved:
- Higher clock speed: The clock produces pulses that synchronise CPU operations; a higher clock speed means more clock cycles / FDE cycles occur per second, allowing more instructions to be executed in a given time period.
- Larger cache: Cache is high-speed memory located on/near the CPU chip. A larger cache can hold more frequently accessed instructions and data, reducing the need to fetch them from slower main memory (RAM), thus reducing wait time / latency.

Marking scheme

(a)(i) 1 mark for:
- Stores / holds the address of the memory location / RAM currently being read from or written to // holds the address where data is to be fetched / sent.
[Max 1]

(a)(ii) 1 mark for:
- Stores / holds the instruction currently being decoded / executed.
[Max 1]

(a)(iii) 2 marks:
- Address bus [1]
- Unidirectional [1]
[Max 2]

(b) 1 mark per valid point up to max 4:
- MP1: The Program Counter (PC) holds the address of the next instruction to be fetched.
- MP2: The address from the PC is copied to the Memory Address Register (MAR) (using the address bus).
- MP3: The instruction at this address is fetched from main memory / RAM (using the data bus) into the Memory Data Register (MDR).
- MP4: The Program Counter (PC) is incremented (by 1).
- MP5: The contents / instruction in the MDR are copied to the Current Instruction Register (CIR).
[Max 4]

(c) 1 mark per valid point up to max 3:
- MP1 (Clock speed): Higher clock speed means more clock cycles / pulses per second // higher frequency of FDE cycles.
- MP2 (Clock speed effect): More instructions can be processed / executed per unit of time / per second.
- MP3 (Cache size): Cache is faster to access than main memory (RAM) // larger cache holds more frequently used data/instructions.
- MP4 (Cache effect): Reduces the time CPU spends waiting for data / reduces number of fetches from RAM.
[Max 3]
Question 4 · structured
11 marks
A retail company installs automated self-checkout kiosks in its stores.

(a) (i) Identify two input devices built into the self-checkout kiosk and state the purpose of each device in this context. [2]

(ii) Identify one output device built into the self-checkout kiosk and state its purpose in this context. [1]

(b) The kiosk uses a Solid-State Drive (SSD) for secondary storage rather than a Hard Disk Drive (HDD).

(i) Describe how data is stored and retrieved in solid-state storage. [3]

(ii) Give two reasons why an SSD is more suitable than an HDD for this kiosk. [2]

(c) The kiosk also contains an embedded system that monitors temperature to prevent internal hardware overheating.

Explain the differences between an embedded system and a general-purpose computer. [3]
Show answer & marking scheme

Worked solution

(a)(i) Two input devices and purposes (any two pairs):
- Barcode scanner / QR code scanner: Reads product barcodes to retrieve item details and prices.
- Touch screen (capacitive/resistive/infrared): Allows the customer to select options, enter quantities, or confirm payment.
- Weighing scale / pressure sensor: Checks the weight of bagged items to verify the correct item was placed.
- Microphone: Allows voice commands or communication with an attendant.

(ii) One output device and purpose (any one):
- LED/LCD screen / Touch screen (as output): Displays total cost, itemised receipt on screen, and step-by-step instructions.
- Speaker: Outputs audible beeps for scanned items or voice prompts for customer guidance.
- Actuator: Controls the mechanical lock/release of receipt dispensing or change dispenser.

(b)(i) Solid-state storage operation:
- Uses flash memory consisting of an array of transistors / NAND flash chips.
- Uses floating gate and control gate transistors.
- Electric current is applied to trap electrons within floating gates (using Fowler-Nordheim tunnelling).
- The presence or absence of trapped electrical charge in a cell alters its threshold voltage, which is read as binary 1s and 0s.
- It has no moving parts; data is read and written electronically in blocks/pages.

(ii) Reasons SSD is more suitable than HDD:
- Faster read/write access speeds leading to faster boot times and quicker application responsiveness.
- More durable / robust with no moving parts, so it is not damaged by physical vibration or accidental knocks.
- Runs silently and generates less heat, reducing cooling requirements inside a compact kiosk enclosure.
- Lower power consumption.

(c) Differences between an embedded system and a general-purpose computer:
- Purpose: An embedded system is designed to perform a single, specific, dedicated task (e.g., temperature control), whereas a general-purpose computer can run a wide range of different applications and perform varied tasks.
- Software/OS: An embedded system usually has fixed firmware stored in ROM and cannot be reprogrammed by typical users, whereas a general-purpose computer runs a full operating system where users can install and delete software.
- Hardware resources: An embedded system has minimal, low-cost processing power and limited memory tailored exactly to its task, whereas a general-purpose computer has expandable and much larger processing and storage resources.

Marking scheme

(a)(i) 1 mark for each valid input device + matching purpose (max 2 marks):
- Barcode scanner / QR code scanner [1] — to scan item barcodes / lookup prices [1]
- Touch screen [1] — to allow user selection of on-screen buttons / options [1]
- Weighing scale / weight sensor / pressure sensor [1] — to verify weight of scanned items in the bagging area [1]
- Microphone [1] — to accept voice input / speak to assistant [1]
[Max 2]

(a)(ii) 1 mark for valid output device + matching purpose:
- Screen / LCD screen / LED screen [1] — to display instructions / prices / bill [1]
- Speaker [1] — to output sound alerts / voice guidance [1]
- Actuator [1] — to dispense cash / coins / receipt [1]
[Max 1]

(b)(i) 1 mark per valid point up to max 3:
- MP1: Uses flash memory / NAND flash chips / transistors / silicon chips.
- MP2: Uses floating gates and control gates.
- MP3: Traps electrons / electric charge in floating gates / cells.
- MP4: The presence / level of electrical charge represents binary 1s and 0s.
- MP5: Reading/writing is done purely electronically with no moving parts.
[Max 3]

(b)(ii) 1 mark per valid reason up to max 2:
- MP1: Faster read/write / access speeds (faster system response / boot-up).
- MP2: More reliable / durable as there are no moving parts (resistant to vibration/knocks).
- MP3: Generates less heat / requires less cooling in an enclosed space.
- MP4: Operates silently.
- MP5: Consumes less electrical power.
[Max 2]

(c) 1 mark per valid comparison up to max 3:
- MP1: Embedded system performs a dedicated / single / specific function, whereas general-purpose computer can perform many different / varied tasks.
- MP2: Embedded system runs fixed firmware / software permanently stored in ROM, whereas general-purpose system allows users to install / update various software / apps.
- MP3: Embedded system typically has limited / specialised hardware resources (small RAM/ROM/low-power CPU), whereas general-purpose has larger / expandable resources.
- MP4: Embedded system often does not require a full / complex OS, whereas general-purpose uses a comprehensive OS.
[Max 3]
Question 5 · structured
10 marks
(a) State two differences between a high-level language and a low-level language. [2]

(b) A software developer is preparing a commercial application to distribute to customers. Explain two benefits of using a compiler rather than an interpreter to distribute the completed software. [4]

(c) (i) Identify two code-editing features provided by an Integrated Development Environment (IDE). [2]

(ii) Describe the purpose of error diagnostics in an IDE. [2]
Show answer & marking scheme

Worked solution

(a) Differences between high-level and low-level languages:
1. High-level languages are machine-independent / portable across different hardware platforms, whereas low-level languages are specific to a particular CPU architecture / hardware.
2. High-level languages use English-like keywords making them easier for humans to read, write, and debug, whereas low-level languages use mnemonics (assembly) or binary code (machine code) which are harder for humans to understand.

(b) Benefits of using a compiler for distribution:
1. Execution speed: The compiler translates the entire source code into an executable machine code file prior to distribution. This means the program runs much faster when launched by the user because instructions do not have to be translated line-by-line at runtime.
2. Protection of source code / intellectual property: A compiler produces an independent executable file (.exe), so the original source code does not need to be distributed to the customer. This prevents unauthorized viewing, modification, or copying of the developer's proprietary code.

(c) (i) Two IDE code-editing features:
- Auto-completion
- Prettyprint (syntax highlighting / colour coding)

(ii) Purpose of error diagnostics:
Error diagnostics detect and identify syntax errors and run-time errors while the code is being written or tested. They indicate the exact line number of the error and display descriptive messages explaining the problem, allowing the programmer to locate and correct bugs quickly.

Marking scheme

(a) Award 1 mark per valid difference (max 2):
- High-level code is portable / machine-independent // Low-level code is hardware-dependent / machine-specific [1]
- High-level languages use English-like words / easier to read / write / debug // Low-level languages use mnemonics / machine code / harder to read / write [1]
- One high-level command translates to many machine code instructions // One low-level (assembly) instruction translates to one machine code instruction [1]
- Low-level allows direct manipulation of hardware / registers / memory addresses // High-level abstracts hardware details [1]

(b) Award 2 marks per benefit (1 mark for identifying the benefit, 1 mark for explanation) (max 4):
- Benefit: Runs faster / more efficient execution [1]
Explanation: The program is already converted into machine code / does not need translating line-by-line during runtime [1]
- Benefit: Protects source code / intellectual property [1]
Explanation: Only the compiled binary / executable is distributed, preventing users from seeing or altering the source code [1]
- Benefit: Standalone execution [1]
Explanation: The end user does not need to have an interpreter installed to run the application [1]

(c)(i) Award 1 mark for each valid IDE editing feature (max 2):
- Auto-completion / code completion [1]
- Prettyprint / syntax highlighting / colour coding [1]
- Auto-indentation / bracket matching [1]
- Auto-correction [1]

(c)(ii) Award up to 2 marks for description:
- Identifies syntax errors / run-time errors in the program code [1]
- Highlights the line / displays error messages / suggests solutions to assist debugging [1]
Question 6 · theory
10 marks
A student enters the following Uniform Resource Locator (URL) into their web browser to access an online learning system:

`https://www.oakridge-academy.org/portal/login.html`

(a) Identify the following parts of this URL:

(i) Protocol [1]

(ii) Domain name [1]

(iii) Web page / File name [1]

(b) Describe the steps taken by the web browser and network systems to locate, retrieve, and display the web page after the student enters the URL. [4]

(c) The online learning system uses cookies.

(i) Explain the difference between a session cookie and a persistent cookie. [2]

(ii) State one purpose of using a persistent cookie on this website. [1]
Show answer & marking scheme

Worked solution

(a) URL Breakdown:
(i) Protocol: `https` (Hypertext Transfer Protocol Secure)
(ii) Domain name: `www.oakridge-academy.org`
(iii) Web page / File name: `login.html` (or `/portal/login.html`)

(b) Locating and displaying the web page:
1. The web browser sends the domain name to a Domain Name System (DNS) server.
2. The DNS server looks up the domain name and returns the corresponding IP address of the web server to the browser.
3. The browser sends an HTTP/HTTPS request for the web page to the web server using this IP address.
4. The web server processes the request and sends the HTML (and associated files/data) back to the browser.
5. The browser interprets and renders the HTML code to display the web page on the screen.

(c) Cookies:
(i) A session cookie is temporary and stored in primary memory (RAM), being deleted when the browser is closed. A persistent cookie is stored on secondary storage (hard drive/SSD) and remains stored after the browser is closed until its expiry date is reached.
(ii) Storing user login details / username so the user does not have to re-enter them on return visits, or remembering specific user preferences (such as display theme or language).

Marking scheme

(a) (i) 1 mark for:
- https // HTTPS

(ii) 1 mark for:
- www.oakridge-academy.org // oakridge-academy.org

(iii) 1 mark for:
- login.html // /portal/login.html

(b) 1 mark per valid point up to max 4 marks:
- MP1: The browser sends the domain name / URL to a Domain Name Server (DNS)
- MP2: The DNS finds / returns the corresponding IP address (to the browser)
- MP3: The browser sends a request (for the page/files) to the web server (using the IP address)
- MP4: The web server sends the HTML / web page data back to the browser
- MP5: The web browser translates / interprets / renders the HTML to display the web page

(c) (i) 1 mark for each distinguishing characteristic up to max 2 marks:
- MP1: Session cookie is temporary // deleted when browser/session is closed // stored in RAM
- MP2: Persistent cookie is saved on secondary storage // remains after browser is closed // has an expiry date

(ii) 1 mark for a valid purpose:
- Remembering login details / credentials / username
- Saving user preferences / custom settings (e.g. language, theme)
- Tracking user progress across multiple visits
(Do not accept vague answers like 'to save cookies' or 'for security' without context)
Question 7 · theory
11 marks
A logistics company uses autonomous wheeled robots to move parcels around a sorting facility.

(a) (i) State two characteristics of a robot. [2]

(ii) Identify two different sensors from the syllabus list that could be built into the robot to assist with navigation. For each sensor, state the data it detects.

Sensor 1:
Data detected:

Sensor 2:
Data detected: [4]

(iii) State the role of an actuator in this robot. [1]

(b) The logistics company also uses an Artificial Intelligence (AI) system to optimise parcel delivery schedules and vehicle routes.

(i) State what is meant by artificial intelligence (AI). [1]

(ii) The AI route planner uses machine learning rather than an expert system.

Explain how machine learning differs from an expert system. [3]
Show answer & marking scheme

Worked solution

### Part (a)(i)
A robot is defined by three fundamental characteristics:
1. Mechanical structure / framework: It has a physical body designed to interact with the environment.
2. Electrical components: It contains electrical/electronic parts such as sensors (to take inputs), microprocessors (to process data), and actuators (to produce movement).
3. Programmability: It can be programmed to perform specific actions automatically or semi-autonomously.
(Any two points)

### Part (a)(ii)
Valid sensors for navigation include:
- Proximity sensor: Detects the presence or distance of nearby obstacles/objects to avoid collisions.
- Infra-red sensor: Detects reflected infrared light / radiation to measure distance or detect guide lines on the floor.
- Acoustic / ultrasonic sensor: Detects sound waves / echoes to calculate distances to surrounding walls or objects.
- Accelerometer: Detects changes in acceleration, tilt, or orientation of the robot.
(Any two valid pairs of sensor and data detected)

### Part (a)(iii)
An actuator receives electrical output signals from the microprocessor and converts them into physical mechanical movement, such as rotating the motors to drive the wheels or operating a gripper/lifting arm to move parcels.

### Part (b)(i)
Artificial Intelligence (AI) is the simulation of human intelligence or intelligent behaviour by a computer system (e.g., reasoning, learning, and problem-solving).

### Part (b)(ii)
Key differences:
- Learning vs Predefined Rules: Machine learning systems train on large sets of historical data and learn patterns, adapting their algorithms and improving their performance over time without being explicitly programmed for every scenario. Expert systems rely strictly on a fixed knowledge base and a set of predefined IF-THEN rules entered by human subject matter experts.
- Processing Engine: An expert system uses an inference engine to match facts to rules, whereas machine learning uses statistical models and algorithms (e.g. neural networks) to make predictions and decisions.
- Adaptability: Machine learning can automatically adapt to new unseen conditions as new data arrives, whereas an expert system requires a human expert/knowledge engineer to manually update the rule base and knowledge base.

Marking scheme

(a)(i) 1 mark per bullet to max 2:
- Has a mechanical structure // physical framework
- Has electrical / electronic components (e.g. sensors, microprocessors, actuators)
- It is programmable // can be programmed to carry out tasks / follow algorithms

(a)(ii) 1 mark for each valid sensor, 1 mark for corresponding data detected (max 4 marks total):
- Proximity sensor (1) $\rightarrow$ Detects distance to / presence of nearby objects / obstacles (1)
- Infra-red sensor (1) $\rightarrow$ Detects (reflected) infra-red radiation / light / distance (1)
- Acoustic / Ultrasonic sensor (1) $\rightarrow$ Detects sound waves / echoes / sound frequencies (1)
- Accelerometer (1) $\rightarrow$ Detects acceleration / orientation / tilt / change in velocity (1)
(Do not accept sensors outside syllabus list; do not accept just 'detects obstacles' without sensor matching syllabus)

(a)(iii) 1 mark:
- Converts electrical signals (from microprocessor) into physical / mechanical movement // drives the wheels / operates the lifting mechanism

(b)(i) 1 mark:
- The simulation of intelligent / human behaviour by a computer system // ability of a computer system to reason, learn and adapt

(b)(ii) 1 mark per point to max 3:
- Machine learning learns from data / past experience // trains on datasets
- Machine learning adapts / improves without being explicitly programmed / automatically updates its model
- Expert systems rely on a predefined knowledge base and rule base (created by human experts)
- Expert systems use an inference engine to apply rules (to reach conclusions)
- Expert systems cannot learn/adapt automatically // requires manual updates by humans
Question 8 · structured
10 marks
(a) An uncompressed bitmap image has a resolution of 1024 pixels wide by 768 pixels high, and a colour depth of 24 bits.

Calculate the file size of the image in mebibytes (MiB). Show all your working.

[3]

(b) Audio recordings are converted from analogue sound to digital data using sampling.

State what is meant by the term sample resolution and describe the effect of decreasing the sample resolution on the recorded sound file.

[2]

(c) Compression is used to reduce the size of multimedia files.

Explain why lossy compression is suitable for an audio clip, but unsuitable for a text file.

[2]

(d) Run Length Encoding (RLE) is a lossless compression technique.

A single row of monochrome pixels is represented by the following sequence:
`W W W W W B B B B B B W W W W W`
(where W represents a white pixel and B represents a black pixel).

Describe how Run Length Encoding (RLE) reduces the storage requirement of this sequence and state the compressed result.

[3]
Show answer & marking scheme

Worked solution

(a) Calculation:
- Total bits = \(1024 \times 768 \times 24\)
- Total bytes = \(\dfrac{1024 \times 768 \times 24}{8} = 1024 \times 768 \times 3 = 2\,359\,296\text{ bytes}\)
- Conversion to MiB = \(\dfrac{1024 \times 768 \times 3}{1024 \times 1024} = \dfrac{768 \times 3}{1024} = \dfrac{2304}{1024} = 2.25\text{ MiB}\)

(b) Sample Resolution & Effect:
- Definition: The number of bits used to store/represent each sound sample (amplitude).
- Effect of decreasing: File size is smaller // quality/accuracy of the sound decreases / dynamic range is reduced / introduces quantisation noise.

(c) Suitability of Lossy Compression:
- Audio: Unnecessary or imperceptible data (e.g. frequencies outside human hearing range or quieter sounds played simultaneously with louder sounds) can be permanently removed without significantly degrading the listener's experience.
- Text file: Lossy compression permanently discards data; if characters/words are lost, the document becomes corrupt, inaccurate, or unreadable.

(d) Run Length Encoding (RLE):
- Description: Identifies consecutive repeated pixel values (runs) and stores each run as a frequency count followed by the pixel code/colour value, rather than storing each individual pixel separately.
- Compressed result: `5W 6B 5W` (or `5 W 6 B 5 W` / `5, W, 6, B, 5, W`).

Marking scheme

(a) [3 marks total]
- 1 mark for calculating total bytes / bits correctly: \(1024 \times 768 \times 24\) bits OR \(1024 \times 768 \times 3\) bytes \((2\,359\,296)\).
- 1 mark for dividing by \(1024 \times 1024\) (or \(1\,048\,576\)).
- 1 mark for correct final value: 2.25 (MiB).
(Allow full 3 marks for correct final answer with no working shown; allow 1 mark max for dividing by 1,000,000 to give 2.359 / 2.36 MB).

(b) [2 marks total]
- 1 mark for definition: Number of bits per sample // bits used to record/encode each measurement.
- 1 mark for effect: Smaller file size // reduced audio quality / less dynamic range / sound less accurate to original analogue signal.

(c) [2 marks total]
- 1 mark (Audio): Audio data contains sounds beyond human hearing range / quieter sounds masked by louder sounds which can be removed without noticeable loss of quality.
- 1 mark (Text): Removing data from text loses letters/words / corrupts the information / text cannot be reconstructed accurately.

(d) [3 marks total]
- 1 mark for explaining that consecutive repeating items / identical pixels in a run are identified.
- 1 mark for explaining that each run is replaced by a count/frequency and the data value/colour.
- 1 mark for correct compressed output: `5W 6B 5W` (accept equivalent representations such as `5 W, 6 B, 5 W` or `05W06B05W`).

Ready to test yourself?

Turn these notes into exam-style practice. Get unlimited AI questions on this topic with instant marking and explanations.

Practise This Topic

Paper 2: Algorithms, Programming and Logic

Answer all questions. Calculators must not be used. You must use pseudocode or program code where specified.
10 Question · 67 marks
Question 1 · short_answer
3 marks
A registration system for an online library asks users to input personal details.

(a) Identify the most appropriate validation check to ensure a student ID is exactly 8 characters long.

(b) Identify the most appropriate validation check to ensure an age entered is between 11 and 18 inclusive.

(c) State the method of verification that requires a user to enter their chosen password twice to check for discrepancies.
Show answer & marking scheme

Worked solution

(a) A length check ensures that the input contains an exact number of characters or falls within a minimum/maximum character limit.
(b) A range check verifies that numerical data falls within specified lower and upper boundaries (here, 11 to 18).
(c) Double entry verification requires the same data to be input twice by the user, after which the computer compares both entries to ensure they match.

Marking scheme

1 mark per correct answer:
(a) Length check // Length
(b) Range check // Range
(c) Double entry (check) // Double entry // Verification by double entry
Question 2 · structured
4 marks
A 1D array, `Reading`, contains 20 INTEGER elements indexed from 1 to 20.

The following pseudocode algorithm is designed to sort the elements of `Reading` into descending numerical order using a bubble sort.

Complete the pseudocode by writing the missing statements or expressions in the four spaces provided.

```
REPEAT
NoMoreSwaps <- ..................................................... [1]
FOR Index <- 1 TO 19
IF Reading[Index] .................................... Reading[Index + 1] THEN [1]
Temp <- Reading[Index]
Reading[Index] <- .................................... [1]
Reading[Index + 1] <- Temp
NoMoreSwaps <- ..................................... [1]
ENDIF
NEXT Index
UNTIL NoMoreSwaps = TRUE
```
Show answer & marking scheme

Worked solution

To sort the array in descending numerical order using a bubble sort:
1. Before each pass of the array, the Boolean flag `NoMoreSwaps` must be initialised to `TRUE`.
2. In descending order, an element must be swapped if the current element is smaller than the adjacent next element, so the comparison operator is `<`.
3. The standard swap routine saves `Reading[Index]` to `Temp`, copies `Reading[Index + 1]` into `Reading[Index]`, and then assigns `Temp` to `Reading[Index + 1]`.
4. When a swap occurs, `NoMoreSwaps` must be updated to `FALSE` to ensure another pass is executed if necessary.

Marking scheme

1 mark for each correct missing item:

1. `TRUE` // `True`
2. `<`
3. `Reading[Index + 1]`
4. `FALSE` // `False`
Question 3 · Standard Algorithms & Sorting
4 marks
A 1D array, `Reading`, contains 20 INTEGER elements indexed from 1 to 20.

The following pseudocode algorithm is designed to sort the elements of `Reading` into descending numerical order using a bubble sort.

Complete the pseudocode by writing the missing statements or expressions in the four spaces provided.

```
REPEAT
NoMoreSwaps <- ..................................................... [1]
FOR Index <- 1 TO 19
IF Reading[Index] .................................... Reading[Index + 1] THEN [1]
Temp <- Reading[Index]
Reading[Index] <- .................................... [1]
Reading[Index + 1] <- Temp
NoMoreSwaps <- ..................................... [1]
ENDIF
NEXT Index
UNTIL NoMoreSwaps = TRUE
```
Show answer & marking scheme

Worked solution

To sort the array in descending numerical order using a bubble sort:
1. Before each pass of the array, the Boolean flag `NoMoreSwaps` must be initialised to `TRUE`.
2. In descending order, an element must be swapped if the current element is smaller than the adjacent next element, so the comparison operator is `<`.
3. The standard swap routine saves `Reading[Index]` to `Temp`, copies `Reading[Index + 1]` into `Reading[Index]`, and then assigns `Temp` to `Reading[Index + 1]`.
4. When a swap occurs, `NoMoreSwaps` must be updated to `FALSE` to ensure another pass is executed if necessary.

Marking scheme

1 mark for each correct missing item:

1. `TRUE` // `True`
2. `<`
3. `Reading[Index + 1]`
4. `FALSE` // `False`
Question 4 · structured
12 marks
A school inventory system stores equipment codes as strings and logs damaged items to a text file.

(a) The string variable `ItemCode` has been assigned the value `"BioChem-2026"`.

Give the value returned by each of the following statements.

(i) `LENGTH(ItemCode)`

(ii) `SUBSTRING(ItemCode, 1, 3)`

(iii) `LCASE(SUBSTRING(ItemCode, 4, 4))`

[3]

(b) (i) State one reason why data is stored in a file rather than only in variables in main memory (RAM).

[1]

(ii) State what happens to any existing data in a text file when it is opened with the command `OPENFILE "Log.txt" FOR WRITE`.

[1]

(c) A text file named `"EquipmentLog.txt"` contains exactly 50 records. Each record is stored on a separate line and has the format `"XX-9999-ST"`, where the first 7 characters represent the item identifier and the last 2 characters represent the status (`"OK"` for working, `"DM"` for damaged).

Write an algorithm in pseudocode that:
- opens `"EquipmentLog.txt"` for reading
- opens a new file `"DamagedItems.txt"` for writing
- reads each of the 50 records from `"EquipmentLog.txt"`
- extracts the 2-character status from the end of each record
- if the status is `"DM"`, writes the complete record to `"DamagedItems.txt"` and increments a count of damaged items
- closes both files
- outputs a message displaying the total count of damaged items.

[7]
Show answer & marking scheme

Worked solution

(a)
(i) `LENGTH("BioChem-2026")` counts all characters including the hyphen: 12.
(ii) `SUBSTRING("BioChem-2026", 1, 3)` extracts 3 characters starting at index 1: `"Bio"`.
(iii) `SUBSTRING("BioChem-2026", 4, 4)` extracts 4 characters starting at position 4 (`"Chem"`). Applying `LCASE()` gives `"chem"`.

(b)
(i) Main memory (RAM) is volatile, so data is lost when power is turned off or when execution completes. Secondary storage files provide non-volatile/permanent storage.
(ii) Opening a file in `WRITE` mode overwrites the file; any existing data is deleted/lost.

(c)
```text
DECLARE LineData : STRING
DECLARE Status : STRING
DECLARE DamagedCount : INTEGER
DECLARE Count : INTEGER

DamagedCount <- 0
OPENFILE "EquipmentLog.txt" FOR READ
OPENFILE "DamagedItems.txt" FOR WRITE

FOR Count <- 1 TO 50
READFILE "EquipmentLog.txt", LineData
Status <- SUBSTRING(LineData, 9, 2)
IF Status = "DM" THEN
WRITEFILE "DamagedItems.txt", LineData
DamagedCount <- DamagedCount + 1
ENDIF
NEXT Count

CLOSEFILE "EquipmentLog.txt"
CLOSEFILE "DamagedItems.txt"

OUTPUT "Total damaged items: ", DamagedCount
```

Marking scheme

(a) 1 mark for each correct answer:
(i) 12 [1]
(ii) `"Bio"` (accept Bio without quotes) [1]
(iii) `"chem"` (must be lowercase) [1]

(b)
(i) 1 mark for any valid reason:
- RAM is volatile // files provide non-volatile / permanent / persistent storage [1]
- Data needs to be retained when the computer is switched off / program ends [1]

(ii) 1 mark for stating that existing data is deleted / overwritten / wiped / lost [1]

(c) 7 marks maximum:
- MP1: Initialising counter variable to 0 [1]
- MP2: Opening `"EquipmentLog.txt"` for `READ` AND `"DamagedItems.txt"` for `WRITE` [1]
- MP3: Loop correctly running 50 times (e.g. `FOR Count <- 1 TO 50` / `WHILE` / `REPEAT`) [1]
- MP4: Correctly reading record from `"EquipmentLog.txt"` inside the loop [1]
- MP5: Correctly isolating status using `SUBSTRING(LineData, 9, 2)` or `SUBSTRING(LineData, LENGTH(LineData)-1, 2)` [1]
- MP6: Correct `IF` condition checking for `"DM"` AND writing record to `"DamagedItems.txt"` AND incrementing counter [1]
- MP7: Closing both files (`CLOSEFILE`) AND outputting total count with an appropriate message [1]
Question 5 · Loop Classifications & Logic Debugging
4 marks
(a) Complete the table to identify the loop construct described in each row. Choose from:
- `FOR ... TO ... NEXT`
- `REPEAT ... UNTIL`
- `WHILE ... DO ... ENDWHILE`

| Description | Loop construct |
| :--- | :--- |
| A loop where the number of iterations is fixed and known before execution begins | .................................................... |
| A post-condition loop that always executes its body at least once | .................................................... |

(b) A programmer writes the following pseudocode algorithm to input 50 exam scores and count how many students scored 50 marks or above (a pass).

```text
01 PassCount <- 1
02 FOR Index <- 1 TO 50
03 INPUT Score
04 IF Score > 50 THEN
05 PassCount <- PassCount + 1
06 ENDIF
07 NEXT Index
08 OUTPUT PassCount
```

Identify the line number of two logic errors in the algorithm and write the corrected line of pseudocode for each.

Error 1:
Line number: .................
Corrected line: .................

Error 2:
Line number: .................
Corrected line: .................
Show answer & marking scheme

Worked solution

(a)
- First row: `FOR ... TO ... NEXT` (count-controlled loop).
- Second row: `REPEAT ... UNTIL` (post-condition loop).

(b)
- Error 1: Line 01 initializes `PassCount` to 1 instead of 0, which would result in an overcount of 1.
Corrected line: `PassCount <- 0`
- Error 2: Line 04 uses `Score > 50`, which excludes students who score exactly 50 marks (a pass).
Corrected line: `IF Score >= 50 THEN` (or `IF Score > 49 THEN`)

Marking scheme

(a) 1 mark for each correct loop construct:
- Row 1: `FOR ... TO ... NEXT` // `FOR` loop // count-controlled [1]
- Row 2: `REPEAT ... UNTIL` // `REPEAT` loop // post-condition [1]

(b) 1 mark for each line number and corresponding correction:
- Line 01: `PassCount <- 0` [1]
- Line 04: `IF Score >= 50 THEN` // `IF Score > 49 THEN` [1]
Question 6 · Loop Classifications & Logic Debugging
4 marks
(a) State the classification of each of the following loop constructs as either pre-condition, post-condition, or count-controlled:

(i) `WHILE ... DO ... ENDWHILE`

(ii) `REPEAT ... UNTIL`

(b) The following pseudocode algorithm is designed to continuously input positive item prices, add them to `Total`, and stop when `-1` is entered. The terminating value (`-1`) must not be added to `Total`.

```text
01 Total <- 0
02 INPUT Price
03 WHILE Price <> -1 DO
04 INPUT Price
05 Total <- Total + Price
06 ENDWHILE
07 OUTPUT Total
```

(i) Explain why this algorithm produces an incorrect value for `Total`.

(ii) State how the statements inside the `WHILE` loop (lines 04 and 05) should be corrected so that the algorithm functions as intended.
Show answer & marking scheme

Worked solution

(a)
(i) `WHILE ... DO ... ENDWHILE` tests the condition before running the body, so it is a pre-condition loop.
(ii) `REPEAT ... UNTIL` tests the condition at the end of the body, so it is a post-condition loop.

(b)
(i) On line 04, `INPUT Price` occurs before `Total <- Total + Price`. Consequently, the initial price entered on line 02 is never added to `Total` (it is immediately overwritten), and when `-1` is entered to terminate the loop, `-1` is added to `Total` on line 05.
(ii) The order of execution inside the loop must be reversed: add `Price` to `Total` first, and then prompt for the next `Price` at the end of the iteration:
`04 Total <- Total + Price`
`05 INPUT Price`

Marking scheme

(a)(i) Pre-condition [1]
(a)(ii) Post-condition [1]

(b)(i) 1 mark for any one valid explanation:
- The first price entered (on line 02) is overwritten before it is added to `Total` [1]
- The terminating / rogue value (`-1`) is added to `Total` [1]

(b)(ii) 1 mark for:
- Swap line 04 and line 05 // Place `Total <- Total + Price` before `INPUT Price` [1]
Question 7 · structured
7 marks
An astronomy society uses a database table named `TELESCOPE` to store details of equipment available for members to borrow.

Part of the `TELESCOPE` table is shown:

| TelescopeID | ApertureMM | Motorised | RentalPrice | DateAcquired |
| :--- | :--- | :--- | :--- | :--- |
| TL101 | 150 | TRUE | 14.50 | 12/04/2022 |
| TL104 | 90 | FALSE | 8.00 | 05/09/2021 |
| TL108 | 200 | TRUE | 22.00 | 18/01/2023 |
| TL112 | 100 | FALSE | 9.50 | 30/11/2022 |
| TL115 | 130 | TRUE | 16.00 | 14/07/2023 |

(a) State the purpose of a primary key. [1]

(b) Identify the most appropriate data type for each of the following fields:
- `TelescopeID`
- `Motorised`
- `RentalPrice` [3]

(c) Write a Structured Query Language (SQL) statement to display the `TelescopeID` and `RentalPrice` of all telescopes with an `ApertureMM` greater than 100 that are motorised (`Motorised = TRUE`). The results should be displayed in descending order of `RentalPrice`. [3]
Show answer & marking scheme

Worked solution

(a) A primary key is a field (or combination of fields) that uniquely identifies each individual record/row in a database table.

(b)
- `TelescopeID`: Text / Alphanumeric (contains both letters and numbers, e.g., 'TL101')
- `Motorised`: Boolean (holds only one of two logical values: TRUE or FALSE)
- `RentalPrice`: Real / Currency (contains numerical data with decimal/fractional parts)

(c)
```sql
SELECT TelescopeID, RentalPrice
FROM TELESCOPE
WHERE ApertureMM > 100 AND Motorised = TRUE
ORDER BY RentalPrice DESC;
```

Marking scheme

(a) 1 mark for:
- Uniquely identifies a record // uniquely identifies a row in a table [1]

(b) 1 mark for each correct data type:
- `TelescopeID`: Text // Alphanumeric // String [1]
- `Motorised`: Boolean [1]
- `RentalPrice`: Real // Currency // Decimal [1]
(Note: Reject Integer for RentalPrice)

(c) 1 mark for each of the following points (up to max 3):
- MP1: Correct `SELECT` and `FROM` clauses: `SELECT TelescopeID, RentalPrice FROM TELESCOPE` [1]
- MP2: Correct `WHERE` clause with logical AND: `WHERE ApertureMM > 100 AND Motorised = TRUE` (accept `Motorised = True` or `Motorised`) [1]
- MP3: Correct `ORDER BY` clause: `ORDER BY RentalPrice DESC` // `ORDER BY RentalPrice DESCENDING` [1]
Question 8 · structured
7 marks
(a) State the name of the standard flowchart symbol used to represent each of the following:

(i) A call to a separate, non-linked subroutine.

(ii) A condition check such as testing whether `ActivityLevel = 'H'`.

(b) An algorithm in a fitness application uses a function to calculate a user's daily calorie target.

The logic of the flowchart is described as follows:
- The function is named `CalorieTarget` and takes two parameters: `Weight` of data type `REAL` and `ActivityLevel` of data type `CHAR`.
- If `ActivityLevel` is `'H'`, a multiplier variable `BaseMultiplier` is set to 35.
- Otherwise, if `ActivityLevel` is `'M'`, `BaseMultiplier` is set to 30.
- For any other value of `ActivityLevel`, `BaseMultiplier` is set to 25.
- The function calculates the daily calorie target by multiplying `Weight` by `BaseMultiplier`, rounds the result to 0 decimal places using the library routine `ROUND()`, and returns this integer value.

Write pseudocode to define the function `CalorieTarget`.
Show answer & marking scheme

Worked solution

(a)
(i) Subroutine (or Predefined process symbol)
(ii) Decision (or Diamond symbol)

(b)
```
FUNCTION CalorieTarget(Weight : REAL, ActivityLevel : CHAR) RETURNS INTEGER
DECLARE BaseMultiplier : INTEGER
DECLARE Target : INTEGER
IF ActivityLevel = 'H' THEN
BaseMultiplier <- 35
ELSE
IF ActivityLevel = 'M' THEN
BaseMultiplier <- 30
ELSE
BaseMultiplier <- 25
ENDIF
ENDIF
Target <- ROUND(Weight * BaseMultiplier, 0)
RETURN Target
ENDFUNCTION
```

Note: A `CASE OF` structure is also fully acceptable:
```
FUNCTION CalorieTarget(Weight : REAL, ActivityLevel : CHAR) RETURNS INTEGER
DECLARE BaseMultiplier : INTEGER
CASE OF ActivityLevel
'H' : BaseMultiplier <- 35
'M' : BaseMultiplier <- 30
OTHERWISE BaseMultiplier <- 25
ENDCASE
RETURN ROUND(Weight * BaseMultiplier, 0)
ENDFUNCTION
```

Marking scheme

(a)(i) 1 mark for:
- Subroutine // Predefined process

(a)(ii) 1 mark for:
- Decision

(b) 5 marks maximum:
- 1 mark: Correct `FUNCTION` header with both parameters (`Weight : REAL`, `ActivityLevel : CHAR`) and `RETURNS INTEGER` (and matching `ENDFUNCTION`).
- 1 mark: Correct selection construct (`IF ... ELSE` or `CASE OF`) testing `'H'`, `'M'`, and default/otherwise.
- 1 mark: Correct assignment of multiplier values (35, 30, and 25).
- 1 mark: Correct calculation `Weight * BaseMultiplier` combined with `ROUND(..., 0)`.
- 1 mark: Correct `RETURN` of the calculated value.
Question 9 · structured
7 marks
(a) State two reasons why subroutines (procedures and functions) are used when developing programs.

(b) A security system uses a structured subroutine to process access requests at a research facility. The logic is defined as follows:
- The subroutine is a procedure named `ProcessEntry` that receives two parameters: `CardID` (data type `INTEGER`) and `FloorCode` (data type `INTEGER`).
- It validates whether `FloorCode` is between 1 and 5 inclusive. If not, it outputs `"Invalid Floor"`.
- If `FloorCode` is valid, it checks whether `CardID` is a valid 4-digit number (from 1000 to 9999 inclusive).
- If `CardID` is valid, it outputs `"Access Granted"` and calls a separate subroutine `LogAccess`, passing `CardID` and `FloorCode` as arguments.
- If `CardID` is invalid, it outputs `"Invalid Card"`.

(i) Identify the two parameters passed to `ProcessEntry`.

(ii) Write pseudocode to define the procedure `ProcessEntry`.
Show answer & marking scheme

Worked solution

(a)
Two reasons from:
- Code reusability: subroutines can be written once and executed multiple times from different parts of the program.
- Modularity and decomposition: breaking a large complex task into smaller, manageable units.
- Easier maintenance and debugging: errors can be isolated and corrected within a specific subroutine without affecting the rest of the program.
- Team development: allows multiple programmers to work independently on different subroutines.

(b)(i)
`CardID` and `FloorCode`

(b)(ii)
```
PROCEDURE ProcessEntry(CardID : INTEGER, FloorCode : INTEGER)
IF FloorCode >= 1 AND FloorCode <= 5 THEN
IF CardID >= 1000 AND CardID <= 9999 THEN
OUTPUT "Access Granted"
CALL LogAccess(CardID, FloorCode)
ELSE
OUTPUT "Invalid Card"
ENDIF
ELSE
OUTPUT "Invalid Floor"
ENDIF
ENDPROCEDURE
```

Marking scheme

(a) 1 mark per valid reason (max 2):
- Code reusability // can be called multiple times without rewriting
- Easier to debug / isolate faults / test individual components
- Improves maintainability / readability of code
- Supports decomposition / breaks problem into smaller sub-tasks
- Facilitates collaboration / multiple developers working simultaneously

(b)(i) 1 mark for:
- `CardID` AND `FloorCode` (both required)

(b)(ii) 4 marks maximum:
- 1 mark: Correct `PROCEDURE` header with parameters and data types (`CardID : INTEGER, FloorCode : INTEGER`) and matching `ENDPROCEDURE`.
- 1 mark: Correct validation condition for `FloorCode` (between 1 and 5 inclusive) and outputting `"Invalid Floor"` when false.
- 1 mark: Correct validation condition for `CardID` (between 1000 and 9999 inclusive) and outputting `"Invalid Card"` when false.
- 1 mark: Outputting `"Access Granted"` AND correct procedure call syntax `CALL LogAccess(CardID, FloorCode)`.
Question 10 · extended_text
15 marks
A local fitness centre records attendance for 30 members during a weekly fitness challenge. For each member, the following data must be stored:
- Member ID (a 4-digit integer from 1000 to 9999)
- Member name (string)
- Number of sessions attended during the week (an integer from 0 to 10 inclusive)

Write a program in pseudocode or program code that satisfies the following requirements:

1. Data input and validation:
- Input the Member ID, Member name, and number of sessions attended for all 30 members.
- Validate the Member ID (must be between 1000 and 9999 inclusive).
- Validate the number of sessions attended (must be between 0 and 10 inclusive).
- Store the validated data in suitable one-dimensional arrays.

2. Statistical analysis and output:
- Calculate the total number of sessions attended by all 30 members.
- Calculate and output the average number of sessions attended per member, rounded to 1 decimal place.
- Find and output the highest number of sessions attended, along with the ID and name of every member who achieved this maximum score.

3. Search functionality:
- Allow the user to enter a Member ID to search for.
- Perform a search to find the member.
- If found, output the member's name and the number of sessions attended.
- If not found, output an appropriate message indicating that the member ID does not exist.

You must use meaningful variable names and include comments to document your code.
Show answer & marking scheme

Worked solution

```text
// Declare constants and arrays
CONSTANT TotalMembers <- 30
DECLARE MemberID : ARRAY[1:TotalMembers] OF INTEGER
DECLARE MemberName : ARRAY[1:TotalMembers] OF STRING
DECLARE SessionsAttended : ARRAY[1:TotalMembers] OF INTEGER

DECLARE TotalSessions : INTEGER
DECLARE AverageSessions : REAL
DECLARE MaxSessions : INTEGER
DECLARE SearchID : INTEGER
DECLARE Found : BOOLEAN
DECLARE Index : INTEGER
DECLARE TempID : INTEGER
DECLARE TempSessions : INTEGER
DECLARE TempName : STRING

TotalSessions <- 0
MaxSessions <- -1

// Task 1: Input and validation for 30 members
FOR Index <- 1 TO TotalMembers
OUTPUT "Enter 4-digit Member ID (1000 to 9999) for member ", Index, ": "
INPUT TempID
WHILE TempID < 1000 OR TempID > 9999 DO
OUTPUT "Invalid ID. Re-enter 4-digit ID (1000 to 9999): "
INPUT TempID
ENDWHILE
MemberID[Index] <- TempID

OUTPUT "Enter Member Name: "
INPUT MemberName[Index]

OUTPUT "Enter sessions attended (0 to 10): "
INPUT TempSessions
WHILE TempSessions < 0 OR TempSessions > 10 DO
OUTPUT "Invalid number of sessions. Re-enter (0 to 10): "
INPUT TempSessions
ENDWHILE
SessionsAttended[Index] <- TempSessions

// Running total and tracking maximum
TotalSessions <- TotalSessions + SessionsAttended[Index]
IF SessionsAttended[Index] > MaxSessions THEN
MaxSessions <- SessionsAttended[Index]
ENDIF
NEXT Index

// Task 2: Calculate and output statistics
AverageSessions <- ROUND(TotalSessions / TotalMembers, 1)
OUTPUT "Total sessions attended by all members: ", TotalSessions
OUTPUT "Average sessions attended per member: ", AverageSessions

OUTPUT "Highest sessions attended: ", MaxSessions
OUTPUT "Member(s) with highest attendance:"
FOR Index <- 1 TO TotalMembers
IF SessionsAttended[Index] = MaxSessions THEN
OUTPUT "ID: ", MemberID[Index], ", Name: ", MemberName[Index]
ENDIF
NEXT Index

// Task 3: Search for a specific member
OUTPUT "Enter Member ID to search: "
INPUT SearchID
Found <- FALSE
Index <- 1

WHILE Index <= TotalMembers AND Found = FALSE DO
IF MemberID[Index] = SearchID THEN
Found <- TRUE
OUTPUT "Member Found: ", MemberName[Index]
OUTPUT "Sessions attended: ", SessionsAttended[Index]
ELSE
Index <- Index + 1
ENDIF
ENDWHILE

IF Found = FALSE THEN
OUTPUT "Error: Member ID not found."
ENDIF
```

Marking scheme

### Level of Response Marking Grid

#### AO2: Application (max 9 marks)
- Band 3 (7–9 marks):
- All parts of the scenario are addressed with clear, effective logic.
- Appropriate data types and array data structures are declared and used correctly.
- Input validation is implemented fully for both Member ID and Sessions Attended using suitable conditional loops.
- Correct logic for calculating total, average (rounded), finding maximum (including multiple members with maximum), and a linear search with appropriate output for found/not found.
- Band 2 (4–6 marks):
- Most parts of the scenario are addressed, but some minor logical omissions exist (e.g., validation handles only one field, or average calculation omits rounding, or maximum output only outputs the first member).
- Arrays are used to store data, though indices or structure may contain minor errors.
- Band 1 (1–3 marks):
- Limited attempt to address the scenario.
- Basic input/output statements present, but lacks proper iteration, validation, or search logic.
- 0 marks: No creditable response.

#### AO3: Evaluation and Solution Design (max 6 marks)
- Band 3 (5–6 marks):
- The algorithm is fully functional, robust, and correctly structured.
- Meaningful identifier names are used consistently throughout.
- Thorough and relevant comments explain key stages of the program (e.g. data validation, statistical processing, search).
- Band 2 (3–4 marks):
- The algorithm demonstrates sound structure with mostly meaningful identifiers.
- Some comments are included, though explanations may be brief or incomplete.
- Band 1 (1–2 marks):
- Poorly structured solution with minimal or no commenting.
- Generic variable names (e.g., `x`, `a`, `temp`) dominate.
- 0 marks: No creditable response.

Wondering how well you actually know this?

thinka is an AI practice app for GCSE & A-Level 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? Practise unlimited on thinka, instant answers included.

Start Practising Free