An original Thinka practice paper modelled on the structure and difficulty of the Jun 2023 (V2) Cambridge International A Level Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
Paper 12 Computer Systems
Answer all questions. Calculators must not be used.
10 PastPaper.question · 75 PastPaper.marks
PastPaper.question 1 · Short Answer
3 PastPaper.marks
Computer scientists and programmers frequently use the hexadecimal number system rather than the binary number system. Explain three reasons why programmers prefer to use hexadecimal.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Hexadecimal is a base-16 system, whereas binary is base-2. Because 16 is a power of 2 (\(2^4 = 16\)), exactly one hexadecimal digit maps to a 4-bit nibble. Programmers prefer it because a 16-bit binary number like 1010110011110001 can be represented as a much shorter 4-digit hex number (ACF1). This compactness makes it far easier for humans to read, write, and remember, reducing the likelihood of typing or reading errors during debugging or system configuration. It is also extremely simple to convert back and forth compared to converting between denary and binary.
PastPaper.markingScheme
Award 1 mark for each valid reason, up to a maximum of 3 marks: 1. It is shorter or more compact to write/display (e.g. fewer digits represent the same value). 2. It is easier for humans to read, write, and remember. 3. There is a lower probability of making transcription or typing errors. 4. It is easy or straightforward to convert to and from binary (1 hex digit = 4 bits). Note: Reject statements claiming 'it takes up less memory in the computer' or 'it runs faster'.
PastPaper.question 2 · Short Answer
3 PastPaper.marks
Parallel data transmission is often used for short distances inside a computer system. Describe three reasons why serial data transmission is preferred over parallel data transmission for long-distance communication.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
In parallel transmission, multiple bits are sent simultaneously over multiple wires. Over long distances, signals can arrive out of sync due to slight physical differences in the wires; this is called data skewing. Additionally, parallel wires close together suffer from crosstalk (electromagnetic interference). Serial transmission uses a single wire to send bits one after another, eliminating skewing and reducing crosstalk, while being much cheaper and less bulky to install.
PastPaper.markingScheme
Award 1 mark for each valid point up to 3: - Serial transmission does not suffer from data skewing (where bits arrive at different times because they travel on separate wires). - Serial has less crosstalk / electromagnetic interference (as there are fewer adjacent wires carrying signals). - Serial cabling is cheaper / easier to install over long distances (requires only a single data channel/wire). - Serial maintains signal integrity better over longer distances.
PastPaper.question 3 · Short Answer
3 PastPaper.marks
An interrupt is a signal sent to the CPU from a device or program. Describe the process that occurs when the CPU receives and services an interrupt signal.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
When an interrupt signal is received, the CPU completes its current execution cycle. It then saves the current state (including registers and the program counter) onto a stack so it can resume later. The CPU identifies the interrupt source and executes the corresponding Interrupt Service Routine (ISR). Once the ISR is finished, the CPU restores the saved state and continues the original task.
PastPaper.markingScheme
Award 1 mark for each valid step up to 3: - The CPU finishes executing the current instruction. - The contents of the registers / program counter / CPU state are saved (on a stack). - The CPU loads and runs the appropriate Interrupt Service Routine (ISR) / interrupt handler. - After the interrupt is serviced, the saved register values/state are restored. - The CPU resumes the execution of the interrupted program.
PastPaper.question 4 · Short Answer
3 PastPaper.marks
Explain how a Distributed Denial of Service (DDoS) attack is carried out on a web server, and describe its effect on legitimate users.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
A Distributed Denial of Service (DDoS) attack begins by infecting a large number of internet-connected devices with malware, turning them into a network of 'zombies' known as a botnet. The attacker then commands the botnet to send a massive flood of requests or fake traffic to a single target web server at the same time. The server's bandwidth or processing resources become completely overwhelmed, preventing it from responding to legitimate traffic, which makes the website slow or entirely offline for genuine users.
PastPaper.markingScheme
Award 1 mark for each valid point up to 3: - An attacker infects multiple computers/devices with malware to build a botnet / group of zombie computers. - The botnet simultaneously sends a massive volume of traffic / requests to the target web server. - The server's resources / bandwidth / processing power is overwhelmed/overloaded. - Legitimate users are prevented from accessing the service / website becomes offline or unresponsive.
PastPaper.question 5 · Short Answer
3 PastPaper.marks
A smartphone can use either a resistive or a capacitive touchscreen. Explain how a resistive touchscreen detects a user's touch input.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
A resistive touchscreen consists of a flexible top layer and a rigid bottom layer, both coated with a conductive resistive material, separated by a tiny gap or spacer dots. When a user presses down, the top layer bends and physically contacts the bottom layer. This contact completes an electrical circuit at that precise point, changing the voltage. A microprocessor measures this change in voltage to calculate the exact X and Y coordinates of the touch point.
PastPaper.markingScheme
Award 1 mark for each valid point up to 3: - The screen has two conductive/resistive layers separated by a gap / spacer dots. - A physical touch / press causes the flexible top layer to bend and contact the bottom layer. - This contact completes an electrical circuit / changes the electrical current/voltage. - A microprocessor/controller calculates the coordinates (X and Y) of the touch based on the position of the change. - Accept: Can be operated with gloves, a stylus, or any physical pointer.
PastPaper.question 6 · Structured Theory
12 PastPaper.marks
**Part (a)** Convert the denary number 141 into: (i) 8-bit binary [2] (ii) Hexadecimal [2] Show your working.
**Part (b)** Show how the negative denary number \(-55\) is represented as an 8-bit signed binary integer using two's complement. Show your working. [4]
**Part (c)** In the context of binary addition of two 8-bit unsigned integers: (i) Explain what is meant by "overflow". [2] (ii) Show an addition of two 8-bit unsigned binary numbers that results in an overflow. [2]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
**Part (a)** (i) Denary 141 to 8-bit binary: - \(141 = 128 + 8 + 4 + 1\) - In 8-bit binary columns (128, 64, 32, 16, 8, 4, 2, 1), this is: **10001101**
(ii) Denary 141 to Hexadecimal: - \(141 / 16 = 8\) with a remainder of \(13\) - \(13\) in hexadecimal is **D** - Therefore, the hexadecimal representation is: **8D**
**Part (b)** Representing \(-55\) in 8-bit two's complement: 1. Find the binary for positive \(+55\): - \(55 = 32 + 16 + 4 + 2 + 1 = 00110111\) 2. Invert all the bits (one's complement): - \(11001000\) 3. Add 1 to the result: - \(11001000 + 1 = 11001001\) - Final answer: **11001001**
**Part (c)** (i) Overflow occurs when the sum of two binary numbers exceeds the maximum value that can be held by the register (for an 8-bit unsigned integer, the maximum is 255). A carry bit is generated from the most significant bit (MSB), which requires a 9th bit that cannot be stored. (ii) Example of overflow: \(11111111\) (255 in denary) + \(00000001\) (1 in denary) = \(100000000\) (256 in denary, requires 9 bits. The 8-bit result becomes 00000000 with a lost carry bit).
PastPaper.markingScheme
**Part (a) [4 marks total]** (i) Max 2 marks: - 1 mark for correct working (e.g., breakdown of powers of 2: 128 + 8 + 4 + 1 or division by 2 method). - 1 mark for the correct 8-bit binary representation: `10001101`. (ii) Max 2 marks: - 1 mark for correct working (e.g., dividing 141 by 16 or converting binary `1000` and `1101` to hex digits). - 1 mark for the correct hexadecimal representation: `8D`.
**Part (b) [4 marks total]** - 1 mark for representing positive +55 in 8-bit binary: `00110111`. - 1 mark for correctly inverting the bits (one's complement): `11001000`. - 1 mark for adding 1 to their inverted binary string. - 1 mark for the correct final binary string: `11001001`.
**Part (c) [4 marks total]** (i) Max 2 marks: - 1 mark for stating that the sum of the numbers exceeds the maximum value that can be stored in the 8-bit register (exceeds 255). - 1 mark for stating that a carry-out from the most significant bit (MSB) occurs / a 9th bit is required. (ii) Max 2 marks: - 1 mark for choosing any two 8-bit binary numbers whose denary sum is greater than 255. - 1 mark for showing the correct addition showing a carry into a non-existent 9th bit (e.g., `11111111 + 00000001 = 100000000` or `10000000 + 10000000 = 100000000`).
PastPaper.question 7 · Structured Theory
12 PastPaper.marks
**Part (a)** The Central Processing Unit (CPU) contains several dedicated registers. Identify the full name of the register that fits each description: (i) Holds the address of the memory location currently being read from or written to. [1] (ii) Holds the actual data or instruction fetched from memory. [1] (iii) Holds the address of the next instruction to be fetched. [1] (iv) Holds the instruction currently being decoded and executed. [1]
**Part (b)** Explain the role of each of the following components in a CPU during the Fetch-Decode-Execute cycle: (i) Program Counter (PC) [2] (ii) Arithmetic Logic Unit (ALU) [2] (iii) Control Unit (CU) [2]
**Part (c)** Describe the function of the following system buses: (i) Data Bus [1] (ii) Address Bus [1]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
**Part (a)** (i) Memory Address Register (MAR) (ii) Memory Data Register (MDR) (iii) Program Counter (PC) (iv) Current Instruction Register (CIR)
**Part (b)** (i) **Program Counter (PC)**: Its main role is to store the memory address of the next instruction to be fetched from RAM. During the fetch stage, after the address is copied to the MAR, the PC is automatically incremented (by 1) to point to the subsequent instruction in sequence. (ii) **Arithmetic Logic Unit (ALU)**: It performs all mathematical calculations (such as addition, subtraction, multiplication, and division) and carries out logical operations / comparisons (such as AND, OR, NOT, and comparing if one value is greater than another). (iii) **Control Unit (CU)**: It coordinates and manages all activities of the CPU by sending control signals to other components (like ALU, registers, and memory). It is also responsible for decoding instructions fetched from memory to determine what operation needs to be performed.
**Part (c)** (i) **Data Bus**: It carries the actual data or instruction code between the CPU, memory, and input/output devices. It is bi-directional. (ii) **Address Bus**: It carries memory addresses from the CPU to RAM (or external components) to specify the source or destination of the data. It is uni-directional.
PastPaper.markingScheme
**Part (a) [4 marks total]** - (i) 1 mark for: Memory Address Register (accept MAR). - (ii) 1 mark for: Memory Data Register (accept MDR). - (iii) 1 mark for: Program Counter (accept PC). - (iv) 1 mark for: Current Instruction Register (accept CIR).
**Part (b) [6 marks total]** (i) Max 2 marks: - 1 mark for stating that it holds the address of the next instruction to be fetched. - 1 mark for stating that it is incremented (by 1) during the fetch stage. (ii) Max 2 marks: - 1 mark for stating that it performs arithmetic calculations / calculations (e.g., +, -, *, /). - 1 mark for stating that it performs logical operations / comparisons (e.g., logical tests, AND/OR/NOT). (iii) Max 2 marks: - 1 mark for stating that it sends control/timing signals to direct flow of data/components. - 1 mark for stating that it decodes instructions (interprets what the instruction means).
**Part (c) [2 marks total]** - (i) 1 mark for: Carries data/instructions between processor and memory/peripherals (must mention that it carries data/instructions or is bi-directional). - (ii) 1 mark for: Carries addresses from processor to memory/peripherals (must mention that it carries addresses or is uni-directional).
PastPaper.question 8 · Structured Theory
12 PastPaper.marks
**Part (a)** Cybersecurity threats exploit different vulnerabilities to compromise users' personal details. (i) Explain how Phishing and Pharming are similar in terms of their goals. [2] (ii) Explain two key differences in how Phishing and Pharming operate to trick users. [4]
**Part (b)** A commercial web server is targeted by a Distributed Denial of Service (DDoS) attack. (i) Explain how a DDoS attack is carried out. [4] (ii) Describe two measures that the web server administrators can implement to mitigate or prevent a DDoS attack. [2]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
**Part (a)** (i) Both Phishing and Pharming share the goal of stealing sensitive personal data, such as usernames, passwords, and banking details (identity theft). They both do this by directing users to fake, lookalike websites that mimic legitimate services. (ii) Differences in operation: - **Phishing** requires active user interaction with a fraudulent link, usually sent via a spam email or SMS message, which tricks them into visiting the fake site. **Pharming**, however, does not require the user to click any link; it infects the user's hard drive (with malware) or poisons the DNS server, automatically redirecting the user to the fake site even if they type the correct URL. - **Phishing** relies primarily on social engineering (e.g., urgent language in emails) to deceive the user, whereas **Pharming** relies on technical manipulation (malware or DNS hijacking) to redirect web traffic.
**Part (b)** (i) How a DDoS attack is carried out: 1. An attacker infects a large number of computers/devices worldwide with malware, turning them into a network of controlled devices called a "botnet". 2. The attacker remotely commands these infected computers (called "bots" or "zombies") to send a massive volume of fake requests/traffic to a single target server simultaneously. 3. The target server is overloaded with more traffic/requests than its bandwidth or CPU can handle. 4. As a result, the server crashes, slows down significantly, or becomes completely unavailable to legitimate users.
(ii) Mitigation measures: 1. **Use of Firewalls**: Configured to monitor traffic and block incoming packets from blacklisted IP addresses or rate-limit requests. 2. **Content Delivery Networks (CDNs) / Traffic Scrubbing**: Distributes the web traffic across multiple global servers, filtering out malicious request patterns before they reach the main server. 3. **Intrusion Prevention Systems (IPS)**: Detects anomalous traffic patterns and blocks them automatically.
PastPaper.markingScheme
**Part (a) [6 marks total]** (i) Max 2 marks: - 1 mark for stating both aim to obtain personal/sensitive/financial data (or identity theft). - 1 mark for stating both use fake/cloned/fraudulent websites to trick users. (ii) Max 4 marks: - 1 mark for stating Phishing is initiated via an email/message. - 1 mark for stating Phishing relies on user clicking a link/social engineering. - 1 mark for stating Pharming involves malicious code installed on user's device / DNS hijacking. - 1 mark for stating Pharming automatically redirects user even if they type the correct URL / does not require clicking a link.
**Part (b) [6 marks total]** (i) Max 4 marks (1 mark per point): - Attacker infects multiple computers/devices with malware. - These infected devices form a botnet / are called bots/zombies. - The botnet is commanded to send a massive flood of requests/traffic to a target server at the same time. - The server's bandwidth/processing capacity is overloaded, causing it to crash/become offline to legitimate users. (ii) Max 2 marks (1 mark per point, max 2 points): - Implement a firewall (to block known malicious IPs / rate-limit). - Use a CDN / cloud-based DDoS protection service (to distribute and scrub traffic). - Use Intrusion Detection/Prevention Systems (IDS/IPS) to detect anomalous traffic. - Increase network bandwidth to absorb sudden spikes (over-provisioning). - Reject: 'Install antivirus software' (antivirus on server does not directly prevent a DDoS network attack).
PastPaper.question 9 · Structured Theory
12 PastPaper.marks
**Part (a)** A software engineer is deciding whether to distribute their program using a Compiler or an Interpreter. Describe three differences between a Compiler and an Interpreter. [6]
**Part (b)** Assembly language is a low-level language. (i) Describe how Assembly language programs are converted to machine code, identifying the translator used. [2] (ii) State two reasons why a programmer might write code in assembly language rather than a high-level language. [2]
**Part (c)** An Integrated Development Environment (IDE) provides features to help programmers write code. State two features of an IDE that assist in code writing, and briefly describe the purpose of each. [2]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
**Part (a)** Three differences between a Compiler and an Interpreter: 1. **Translation Process**: A compiler translates the entire high-level source code into machine code all at once, whereas an interpreter translates and executes the source code line-by-line. 2. **Output File**: A compiler produces an independent executable file (such as `.exe`) which can run without the source code or compiler, whereas an interpreter does not produce an executable file; the interpreter program must be present every time the code runs. 3. **Error Reporting**: A compiler produces an error report of all syntax errors found in the entire program after attempting translation, whereas an interpreter stops execution as soon as it encounters the first error, making it easier to pinpoint the exact line. 4. **Execution Speed**: Compiled code runs faster because it is already in machine code, while interpreted code runs slower because each line must be translated at runtime.
**Part (b)** (i) Assembly language programs are converted into machine code using a translator called an **assembler**. The assembler translates assembly mnemonics (low-level commands) directly into binary machine instructions (typically on a one-to-one mapping). (ii) Reasons to use assembly language: - To write code that executes highly efficiently / runs very fast. - To occupy minimal memory space (essential for embedded systems with limited RAM). - To directly control specific hardware registers or memory addresses.
**Part (c)** Two features of an IDE for writing code: 1. **Syntax Highlighting (Colour-coding)**: Displays keywords, variables, and strings in different colours, making the code easier to read and helping to identify syntax mistakes early. 2. **Auto-Completion / Code Predictor**: Suggests functions, variable names, or syntax structures as the programmer types, reducing typing errors and speeding up development. 3. **Auto-Indentation**: Automatically aligns code blocks (like loops or if-statements) to improve readability.
PastPaper.markingScheme
**Part (a) [6 marks total]** Award up to 6 marks for three distinct comparison pairs (1 mark for Compiler aspect, 1 mark for matching Interpreter aspect): - **Pair 1**: Compiler translates whole program at once vs Interpreter translates line-by-line. - **Pair 2**: Compiler produces executable file (.exe) vs Interpreter does not produce an executable file. - **Pair 3**: Compiler lists all errors at the end of translation vs Interpreter stops execution immediately when an error is met. - **Pair 4**: Compiled code runs faster (after compilation) vs Interpreted code runs slower (due to translation at runtime). - **Pair 5**: Compiler source code is kept secret (only .exe distributed) vs Interpreter requires source code to be distributed to users.
**Part (b) [4 marks total]** (i) Max 2 marks: - 1 mark for identifying the translator as an **assembler**. - 1 mark for explaining that it translates assembly mnemonics into machine code / binary instructions. (ii) Max 2 marks (1 mark per reason, max 2 reasons): - Direct control of hardware/registers. - Highly efficient execution / runs faster than high-level compiled code. - Uses less memory / produces smaller file size (ideal for embedded systems).
**Part (c) [2 marks total]** Award 1 mark per valid feature-and-description pair (max 2 marks): - **Syntax highlighting**: Color-codes syntax components to make code readable / detect errors. - **Auto-complete / code prediction**: Suggests command names or variables to prevent spelling mistakes. - **Auto-indentation**: Automatically structures blocks of code to show hierarchy. - **Pretty printing**: Formats the code structure automatically. - Note: Reject 'Debugger' / 'Single stepping' / 'Error diagnostics' as they assist in *debugging*, not strictly *writing* code (unless explicitly linked to syntax checking during typing).
PastPaper.question 10 · Structured Theory
12 PastPaper.marks
**Part (a)** Explain the step-by-step process of how a web browser retrieves and displays a webpage when a user enters a URL such as `https://www.example.com`. Refer to the web browser, DNS server, and web server in your answer. [6]
**Part (b)** Describe the role of a web browser. [3]
**Part (c)** (i) Describe the purpose of Hypertext Transfer Protocol Secure (HTTPS). [2] (ii) Define what is meant by a Uniform Resource Locator (URL). [1]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
**Part (a)** The step-by-step process is as follows: 1. The user types the URL (`https://www.example.com`) into the address bar of the web browser. 2. The web browser extracts the domain name (`www.example.com`) from the URL and sends a request to a Domain Name System (DNS) server. 3. The DNS server searches its database to find the IP address that matches the domain name. 4. If found, the DNS server returns the IP address back to the web browser. (If not found, it queries other DNS servers higher up the hierarchy). 5. The web browser uses the IP address to establish a connection and sends an HTTPS request to the web server hosting the website. 6. The web server processes the request, locates the website files (HTML, CSS, images), and transmits them back to the web browser. 7. The web browser translates/renders the HTML, CSS, and script files, displaying the completed web page on the user's screen.
**Part (b)** The primary roles of a web browser include: - Translating/rendering HTML, CSS, and JavaScript files received from web servers into a visual web page. - Managing the transmission protocols (HTTP, HTTPS) to request and receive data. - Providing interactive navigation tools for the user, such as an address bar, back/forward buttons, and bookmarks. - Managing user sessions by storing and retrieving cookies, history, and active login sessions.
**Part (c)** (i) **HTTPS**: Its purpose is to secure the communication channel between the user's browser and the web server. It does this by encrypting all data transmitted, which prevents third parties (like hackers on the same network) from eavesdropping, intercepting, or tampering with sensitive information (such as credit card numbers or passwords). (ii) **URL**: A Uniform Resource Locator is a standardized text address used to identify and locate a specific resource (such as a webpage, file, or image) on the World Wide Web.
PastPaper.markingScheme
**Part (a) [6 marks total]** Award up to 6 marks for points from the following sequence (1 mark per point): - User inputs the URL into the browser. - Browser extracts the domain name and sends it to a DNS server. - DNS server looks up the corresponding IP address (in its database/registry). - DNS server returns the IP address to the web browser. - Browser uses the IP address to send an HTTP/HTTPS request to the web server. - Web server locates the requested webpage files and sends them back to the browser. - Web browser renders/interprets the HTML/CSS/files to display the page to the user.
**Part (b) [3 marks total]** Award up to 3 marks for functions/roles of a browser (1 mark per point): - Renders/translates HTML/CSS/JS files into a visual page. - Handles retrieval protocols (HTTP/HTTPS). - Stores cookies / user history / bookmarks. - Provides a user interface (address bar, navigation buttons).
**Part (c) [3 marks total]** (i) Max 2 marks: - 1 mark for stating it encrypts data sent between browser and server. - 1 mark for stating it prevents data interception / eavesdropping / ensures data integrity. (ii) Max 1 mark: - 1 mark for stating it is the uniform/standard web address of a resource/file on the internet.
Paper 22 Algorithms, Programming and Logic
Answer all questions. Calculators must not be used.
9 PastPaper.question · 53 PastPaper.marks
PastPaper.question 1 · short_answer
4 PastPaper.marks
A pseudocode algorithm is given below:
``` DECLARE Count, Sum, Num : INTEGER Count <- 0 Sum <- 0 WHILE Count < 4 DO OUTPUT "Enter a number: " INPUT Num IF Num > 10 THEN Sum <- Sum + Num ENDIF Count <- Count + 1 ENDWHILE OUTPUT "Total is ", Sum ```
Trace the pseudocode algorithm given the input data: **12, 5, 15, 8**.
State the final values of the variables and the output: 1. Value of `Count` at the end of the algorithm 2. Value of `Sum` at the end of the algorithm 3. Value of `Num` at the end of the algorithm 4. The final `OUTPUT` statement
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Let's trace the execution of the algorithm step-by-step:
- **Initial state:** `Count = 0`, `Sum = 0` - **First loop iteration (Count = 0):** - Input `Num` = 12 - `Num > 10` is true (12 > 10), so `Sum` becomes `0 + 12 = 12` - `Count` is incremented: `Count = 1` - **Second loop iteration (Count = 1):** - Input `Num` = 5 - `Num > 10` is false, so `Sum` remains 12 - `Count` is incremented: `Count = 2` - **Third loop iteration (Count = 2):** - Input `Num` = 15 - `Num > 10` is true (15 > 10), so `Sum` becomes `12 + 15 = 27` - `Count` is incremented: `Count = 3` - **Fourth loop iteration (Count = 3):** - Input `Num` = 8 - `Num > 10` is false, so `Sum` remains 27 - `Count` is incremented: `Count = 4` - **Loop termination:** - `Count` is now 4. The loop condition `Count < 4` evaluates to false, so the loop terminates. - **Output:** - `OUTPUT "Total is ", Sum` prints "Total is 27".
Final Values: - `Count`: 4 - `Sum`: 27 - `Num`: 8 - `OUTPUT`: "Total is 27"
PastPaper.markingScheme
Award 1 mark for each correct final value (total 4 marks): - `Count` = 4 (1 mark) - `Sum` = 27 (1 mark) - `Num` = 8 (1 mark) - `OUTPUT` = "Total is 27" (accept "Total is, 27") (1 mark)
PastPaper.question 2 · short_answer
4 PastPaper.marks
The following pseudocode algorithm is intended to input five positive numbers and calculate their sum. However, it contains four distinct syntax or logic errors.
``` 1 Total <- 0 2 Counter <- 1 3 WHILE Counter < 5 DO 4 INPUT Number 5 Total <- Total + Counter 6 Counter <- Counter - 1 7 ENDWHILE 8 OUTPUT "The total is " + Total ```
Identify the four lines containing errors and state the correction for each error.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The four errors in the pseudocode are: 1. **Line 3 (Loop iteration count error):** The loop is initialized with `Counter <- 1` and checks `Counter < 5`. This loop only executes 4 times (for Counter = 1, 2, 3, 4). To loop 5 times, it must check `Counter <= 5` (or start `Counter` from 0). 2. **Line 5 (Variable tracking error):** The code adds the loop counter `Counter` to the variable `Total` rather than the user input variable `Number`. It should be: `Total <- Total + Number`. 3. **Line 6 (Infinite loop error):** The counter is decremented (`Counter <- Counter - 1`) instead of incremented, meaning `Counter` will never reach 5 and the loop will run indefinitely. It should be: `Counter <- Counter + 1`. 4. **Line 8 (Syntax error in output):** The standard string concatenation operator `+` is used to combine text and a numeric type. In IGCSE pseudocode, a comma `,` must be used instead of `+` to output multiple elements of different data types: `OUTPUT "The total is ", Total`.
PastPaper.markingScheme
Award 1 mark for each correct error identified along with a valid correction (up to 4 marks): - Error on Line 3 correction: change condition to `< 6` or `<= 5` (or initialize counter to 0) (1 mark) - Error on Line 5 correction: change `Counter` to `Number` (`Total <- Total + Number`) (1 mark) - Error on Line 6 correction: change subtraction to addition (`Counter <- Counter + 1`) (1 mark) - Error on Line 8 correction: change `+` to `,` to combine string and integer (1 mark)
PastPaper.question 3 · short_answer
4 PastPaper.marks
A logic system is represented by the following Boolean expression:
$$\text{X} = (\text{A} \text{ AND NOT } \text{B}) \text{ OR } (\text{NOT } \text{A} \text{ AND } \text{C})$$
State the binary value of the output \text{X} for each of the following input combinations: 1. \text{A} = 0, \text{B} = 0, \text{C} = 1 2. \text{A} = 0, \text{B} = 1, \text{C} = 0 3. \text{A} = 1, \text{B} = 0, \text{C} = 0 4. \text{A} = 1, \text{B} = 1, \text{C} = 1
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Let us evaluate the Boolean expression step-by-step for each set of inputs:
1. **A = 0, B = 0, C = 1**: - \text{A AND NOT B} = 0 \text{ AND NOT } 0 = 0 \text{ AND } 1 = 0 - \text{NOT A AND C} = \text{NOT } 0 \text{ AND } 1 = 1 \text{ AND } 1 = 1 - \text{X} = 0 \text{ OR } 1 = 1
2. **A = 0, B = 1, C = 0**: - \text{A AND NOT B} = 0 \text{ AND NOT } 1 = 0 \text{ AND } 0 = 0 - \text{NOT A AND C} = \text{NOT } 0 \text{ AND } 0 = 1 \text{ AND } 0 = 0 - \text{X} = 0 \text{ OR } 0 = 0
3. **A = 1, B = 0, C = 0**: - \text{A AND NOT B} = 1 \text{ AND NOT } 0 = 1 \text{ AND } 1 = 1 - \text{NOT A AND C} = \text{NOT } 1 \text{ AND } 0 = 0 \text{ AND } 0 = 0 - \text{X} = 1 \text{ OR } 0 = 1
4. **A = 1, B = 1, C = 1**: - \text{A AND NOT B} = 1 \text{ AND NOT } 1 = 1 \text{ AND } 0 = 0 - \text{NOT A AND C} = \text{NOT } 1 \text{ AND } 1 = 0 \text{ AND } 1 = 0 - \text{X} = 0 \text{ OR } 0 = 0
PastPaper.markingScheme
Award 1 mark for each correct output value: - Combination 1: X = 1 (1 mark) - Combination 2: X = 0 (1 mark) - Combination 3: X = 1 (1 mark) - Combination 4: X = 0 (1 mark)
PastPaper.question 4 · short_answer
4 PastPaper.marks
A database table named `BOOKS` is used to store details of library inventory. The fields in the table are: - `BookID` (Text, Primary Key) - `Title` (Text) - `Author` (Text) - `YearPublished` (Integer) - `OnLoan` (Boolean: TRUE if borrowed, FALSE if available)
Write a query in database SQL to retrieve and display only the `Title` and `Author` of all books published after the year 2015 that are currently NOT on loan.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To construct this SQL query: 1. Choose the columns to return with the `SELECT` keyword: `SELECT Title, Author` 2. Identify the target table with `FROM`: `FROM BOOKS` 3. Apply constraints with `WHERE` combined by a logical `AND`: - Books published after 2015: `YearPublished > 2015` - Not on loan: `OnLoan = FALSE` (or `OnLoan = False` / `NOT OnLoan`)
Combining these elements, we get: ```sql SELECT Title, Author FROM BOOKS WHERE YearPublished > 2015 AND OnLoan = FALSE; ```
PastPaper.markingScheme
Award 1 mark for each correct clause (up to 4 marks): - `SELECT Title, Author` (1 mark) (reject selection of other fields or wildcard `*`) - `FROM BOOKS` (1 mark) - `WHERE YearPublished > 2015` (1 mark) - `AND OnLoan = FALSE` (accept `AND OnLoan = False` or `AND NOT OnLoan` or `AND OnLoan = 0`) (1 mark)
PastPaper.question 5 · short_answer
4 PastPaper.marks
An 1D array `Names` contains 100 elements indexed 1 to 100. The following pseudocode is designed to find and output the array index of a specific name stored in `SearchName`. However, the algorithm contains four blank lines.
``` DECLARE Index, Position : INTEGER DECLARE Found : BOOLEAN Index <- 1 Position <- -1 Found <- FALSE
WHILE (Index <= 100) AND (Found = FALSE) DO IF Names[Index] = SearchName THEN Found <- TRUE ____________________ (a) ELSE ____________________ (b) ENDIF ENDWHILE
IF Found = TRUE THEN OUTPUT "Name found at position: ", ____________________ (c) ELSE OUTPUT ____________________ (d) ENDIF ```
State the pseudocode statements required to complete lines (a), (b), (c), and (d).
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To complete the search algorithm: - In (a), if the element matches `SearchName`, we set `Found <- TRUE` and record the current index location. This is stored in `Position`. So, `Position <- Index`. - In (b), if the element does not match, we must increment the control loop counter to inspect the next element. So, `Index <- Index + 1`. - In (c), if the name is found, we output its saved index. The printed message should display `Position`. So, `Position`. - In (d), if the name is not found (the `ELSE` branch of `Found = TRUE`), we must output an appropriate error message. So, a string such as `"Name not found"`.
PastPaper.markingScheme
Award 1 mark for each correct statement: - (a) `Position <- Index` (accept `Position = Index`) (1 mark) - (b) `Index <- Index + 1` (accept `Index = Index + 1`) (1 mark) - (c) `Position` (1 mark) - (d) `"Name not found"` (accept any reasonable string literal, must be enclosed in double quotes) (1 mark)
PastPaper.question 6 · short_answer
4 PastPaper.marks
State the correct programming term or Integrated Development Environment (IDE) feature described by each of the following statements:
1. A translator that converts high-level language program source code into machine code line-by-line, executing each instruction as it is processed and stopping immediately if an error is encountered. 2. A translator that converts an entire high-level language program into a standalone executable file of machine code all at once, creating an error report afterwards. 3. An IDE feature that automatically highlights code keywords, variables, and literal values in different colours to improve code readability. 4. An IDE feature that allows a developer to set a specific point where the program will pause execution during debugging, allowing the values of variables to be inspected.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. **Interpreter**: Translates and executes high-level source code line-by-line. 2. **Compiler**: Translates the complete source code file into a standalone machine code executable at once. 3. **Syntax highlighting**: Visual feature in IDEs that color-codes syntax keywords, variables, etc. 4. **Breakpoint**: Debugging feature that pauses program execution at a designated line.
PastPaper.markingScheme
Award 1 mark for each correct term (up to 4 marks): - 1. Interpreter (1 mark) - 2. Compiler (1 mark) - 3. Syntax highlighting (accept colour coding) (1 mark) - 4. Breakpoint (accept debugger / breakpoint tool) (1 mark)
PastPaper.question 7 · trace_table
7 PastPaper.marks
An algorithm is represented by the following pseudocode:
Count1 <- 0 Count2 <- 0 Index <- 0 WHILE Index < 6 DO Val <- Data[Index] IF Val > 0 THEN IF Val MOD 2 = 0 THEN Count1 <- Count1 + 1 ELSE Count2 <- Count2 + 1 ENDIF ENDIF Index <- Index + 1 ENDWHILE OUTPUT Count1, Count2 ```
Complete the trace table below for this algorithm.
Marks are awarded as follows (Max 7): - 1 mark for correct recording of all values of `Val` (12, -5, 0, 18, -3, 7) in the correct order. - 1 mark for correct increment sequence of `Index` (0 to 6). - 2 marks for correct updates to `Count1` (changing to 1 and then 2 at correct points). - 1 mark for correct update to `Count2` (changing to 1 at the correct point). - 2 marks for correct final outputs (1 mark for each correct output value: 2 and 1) at the end of the trace.
*Acceptable alternative representations of the trace table line-by-line distribution are acceptable as long as variable changes are chronologically sound.*
PastPaper.question 8 · trace_table
7 PastPaper.marks
A system processes a sequence of temperature sensor values using a flowchart algorithm. The flowchart is described by the following steps:
1. **Start** 2. Set `Total` to 0, `Count` to 0, and `HighTemp` to 0. 3. Input `Temp` 4. Is `Temp` equal to -99? - **Yes:** Go to step 9 - **No:** Go to step 5 5. Is `Temp` > 35? - **Yes:** Set `HighTemp` to `HighTemp` + 1, then go to step 6 - **No:** Go to step 6 6. Set `Total` to `Total` + `Temp` 7. Set `Count` to `Count` + 1 8. Input next `Temp`, then go to step 4 9. Is `Count` > 0? - **Yes:** Set `Average` to `Total / Count`, Output `Average`, Output `HighTemp`, then Stop. - **No:** Output "No data", then Stop.
Trace the algorithm using the following input data: `32, 38, 30, 42, -99`
A program is required to manage and monitor a smart garden irrigation system. The system has 3 irrigation zones. For each zone, the program must:
1. Input and store the name of the zone (e.g., 'Front Lawn'). 2. Input and store the soil moisture level (as a percentage, from 0 to 100 inclusive) for each of the 7 days of the week. 3. Validate the moisture level input to ensure it is within the range 0 to 100. If the input is invalid, display an error message and prompt the user to re-enter the value until a valid one is provided. 4. Calculate and output the average moisture level for each zone over the 7 days. 5. If the average moisture level for a zone is below 40%, output a message stating: 'Zone [Zone Name] needs urgent watering!'. 6. After processing all 3 zones, identify and output the name and average moisture level of the zone with the lowest overall average.
Write an algorithm in pseudocode or program code to solve this problem. Use meaningful variable names, structure your code clearly, and include comments where appropriate.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The algorithm is designed using nested loops and simple validation structures.
1. **Initialization**: We declare arrays `ZoneNames` and `ZoneAverages` of size 3 to keep track of the names and calculated averages respectively. `MinAverage` is set to an initial high value (101.0) so any real calculated average will be lower than this, and `MinZone` is initialized to an empty string. 2. **First Loop**: Inputs the names of the 3 zones and saves them into the `ZoneNames` array. 3. **Outer Processing Loop**: Loops 3 times (once for each zone). Inside, it resets `TotalMoisture` to 0. 4. **Inner Loop**: Loops 7 times (for the 7 days). It uses a `REPEAT...UNTIL` construct to ensure validation of input between 0 and 100 inclusive. Invalid inputs trigger an error message and are rejected. 5. **Calculations**: Accumulates valid inputs into `TotalMoisture`. After the inner loop, it calculates the average moisture level for the current zone and stores it in `ZoneAverages[i]`. 6. **Evaluation**: Checks if the average moisture is less than 40% and prints the urgent watering message. Compares the average with `MinAverage` to track the lowest zone name and value. 7. **Output**: Finally, prints the name and average moisture of the lowest zone.
PastPaper.markingScheme
Marks are awarded as follows (up to a maximum of 15 marks):
- **1 Mark**: Appropriate declaration/initialization of variables and arrays with correct data types. - **1 Mark**: Storing 3 zone names correctly using a loop. - **1 Mark**: Outer loop runs exactly 3 times (once for each zone). - **1 Mark**: Initializing daily moisture accumulator (`TotalMoisture`) to 0 inside the outer loop (before the inner loop). - **1 Mark**: Inner loop runs exactly 7 times to capture daily readings. - **2 Marks**: Input validation using an appropriate loop (e.g. `REPEAT...UNTIL` or `WHILE`) that checks bounds (>=0 and <=100) and displays an error message on invalid input. - **1 Mark**: Correctly accumulating moisture levels inside the inner loop. - **1 Mark**: Correctly calculating average moisture level (Sum / 7) as a decimal/real value. - **1 Mark**: Outputting the calculated average for each zone with a descriptive message. - **2 Marks**: Checking if the average is below 40% and outputting the specific alert message with the correct zone name. - **2 Marks**: Finding the zone with the lowest average (initializing a minimum tracking variable, comparing each calculated average, and storing both the lowest average and corresponding zone name). - **1 Mark**: Outputting the final lowest average zone name and value at the end of the script.