An original Thinka practice paper modelled on the structure and difficulty of the Nov 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. Total marks: 75. Questions cover computer hardware, storage, networking, security, data transmission, and automated systems.
13 Question · 50.5 marks
Question 1 · Matching & Identification
1.5 marks
An engineer is setting up data transmission links between multiple devices. Match each description of data transmission to its correct technical term.
Description A: Data is sent one bit at a time, over a single wire, in both directions simultaneously. Description B: Data is sent multiple bits at a time, over multiple wires, in one direction only. Description C: Data is sent one bit at a time, over a single wire, in one direction at a time (alternating).
Show answer & marking schemeHide answer & marking scheme
Worked solution
Description A matches 'Full-duplex serial' because data flows in both directions simultaneously (full-duplex) using a single communication channel (serial). Description B matches 'Simplex parallel' because data flows in only one direction (simplex) across multiple wires simultaneously (parallel). Description C matches 'Half-duplex serial' because data flows in both directions but only one direction at a time (half-duplex) using a single channel (serial).
Marking scheme
Award marks as follows (total 1.5 marks): - 0.5 marks for correctly identifying Description A as Full-duplex serial. - 0.5 marks for correctly identifying Description B as Simplex parallel. - 0.5 marks for correctly identifying Description C as Half-duplex serial.
Question 2 · Matching & Identification
1.5 marks
Identify the security term being described in each statement.
Statement A: A type of malicious software that gathers information by secretly monitoring and recording keystrokes on a user's keyboard. Statement B: Malicious code installed on a user's hard drive or web server that automatically redirects them to a fraudulent website, even if they type the correct URL. Statement C: A deceptive email designed to look like it comes from a legitimate bank, requesting the user click a link to update their login credentials.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Statement A describes spyware (specifically a keylogger), which secretly records keyboard inputs to steal data. Statement B describes pharming, which redirects web traffic to fraudulent websites by altering DNS tables or host files. Statement C describes phishing, which relies on social engineering via deceptive emails to capture private user information.
Marking scheme
Award marks as follows (total 1.5 marks): - 0.5 marks for identifying Statement A as Spyware or Keylogger. - 0.5 marks for identifying Statement B as Pharming. - 0.5 marks for identifying Statement C as Phishing.
Question 3 · Matching & Identification
1.5 marks
An automated system controls the temperature in a smart greenhouse. Identify the component type (Sensor, Actuator, or Microprocessor) for each function listed below.
Function A: Compares the incoming temperature reading with a pre-set threshold value. Function B: Measures the physical temperature of the environment and converts it to an analog electrical signal. Function C: Physically opens a ventilation window when a control signal is received.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Function A is performed by a Microprocessor, which executes comparison logic and decides if any actions are required. Function B is performed by a Sensor (specifically a temperature sensor), which reads physical properties of the environment. Function C is performed by an Actuator (such as a motor), which executes a physical action to change the system's state.
Marking scheme
Award marks as follows (total 1.5 marks): - 0.5 marks for matching Function A to Microprocessor. - 0.5 marks for matching Function B to Sensor. - 0.5 marks for matching Function C to Actuator.
Question 4 · Matching & Identification
1.5 marks
Match each of the following storage technologies to its storage category: Magnetic, Optical, or Solid State.
Technology A: A storage medium that uses microscopic pits and lands burnt into a reflective surface, which are read by a laser beam. Technology B: A storage medium that stores data electronically using NAND flash memory chips with no moving parts. Technology C: A storage medium that uses rotating metal platters coated with a magnetic layer, read by a mechanical head.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Technology A describes Optical storage (such as CDs, DVDs, and Blu-rays) using optical lasers and physical pits and lands. Technology B describes Solid State storage (such as SSDs and USB drives) which use microchips with no mechanical parts. Technology C describes Magnetic storage (such as Hard Disk Drives) which write data patterns using magnetizable platters.
Marking scheme
Award marks as follows (total 1.5 marks): - 0.5 marks for matching Technology A to Optical. - 0.5 marks for matching Technology B to Solid State. - 0.5 marks for matching Technology C to Magnetic.
Question 5 · Matching & Identification
1.5 marks
Hexadecimal is widely used in computer systems. Match each scenario to the correct hexadecimal application term from the list: MAC address, IP address, HTML color code, Assembly memory address.
Scenario A: A 12-digit hexadecimal code representing the unique, permanent physical address assigned to a Network Interface Card during manufacture. Scenario B: A 6-digit hexadecimal value (e.g., #FF5733) used to define the intensity of Red, Green, and Blue channels for displaying text on web pages. Scenario C: A hexadecimal representation used by programmers to easily read and debug specific physical locations in primary memory.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Scenario A describes a Media Access Control (MAC) address, which uniquely identifies physical network components. Scenario B describes HTML/CSS color codes, which use 2 hexadecimal digits for each of the red, green, and blue intensities. Scenario C describes memory addresses, which are frequently represented in hexadecimal during software development and debugging to keep the numbers short and readable.
Marking scheme
Award marks as follows (total 1.5 marks): - 0.5 marks for matching Scenario A to MAC address. - 0.5 marks for matching Scenario B to HTML color code (or Hex color code). - 0.5 marks for matching Scenario C to Assembly memory address (or Memory address).
Question 6 · Structured Explanation
4.5 marks
During the fetch-decode-execute cycle, registers are used to manage instruction retrieval. Describe how the Program Counter (PC) and the Memory Address Register (MAR) cooperate to fetch an instruction from Primary Memory.
Show answer & marking schemeHide answer & marking scheme
Worked solution
At the start of the cycle, the Program Counter (PC) holds the memory address of the next instruction to be fetched. This address is sent over the address bus to the Memory Address Register (MAR). At the same time, the PC is incremented by 1 so that it points to the next instruction in sequence. The MAR holds this address while a control signal is sent to primary memory to fetch the instruction from that specific location, placing it on the data bus to be sent to the Memory Data Register (MDR).
Marking scheme
Award marks as follows (Max 4.5 marks): - 1 mark: For stating that the PC holds/stores the address of the next instruction to be fetched. - 1 mark: For explaining that the address is copied from the PC to the MAR. - 1 mark: For explaining that the PC is incremented (by 1) to point to the next instruction. - 1 mark: For explaining that the MAR holds this address while the primary memory is accessed to retrieve the data/instruction. - 0.5 mark: For mentioning that the fetched instruction is then loaded into the Memory Data Register (MDR) via the data bus.
Question 7 · Structured Explanation
4.5 marks
A manufacturing plant needs to transmit sensor reading data to a control center located 2 km away. Explain why serial simplex data transmission is more suitable for this specific scenario than parallel duplex transmission.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Over a long distance of 2 km, parallel transmission suffers from data skew where bits travel at slightly different speeds and arrive out of alignment, corrupting the data. Serial transmission sends data one bit at a time down a single channel, eliminating skew. It is also significantly cheaper as it requires fewer physical wires. Simplex is selected because the sensor only needs to send data unidirectionally to the control center; there is no operational requirement for the control center to send data back to the sensor, making duplex redundant.
Marking scheme
Award marks as follows (Max 4.5 marks): - 1 mark: Serial transmission prevents data skew (bits arriving out of synchronization) over long distances (2 km). - 1 mark: Serial transmission is significantly cheaper / easier to install over long distances because it uses a single physical channel / fewer wires. - 1 mark: Simplex data transmission allows data to flow in one direction only, which matches the requirements of sensors sending data to a central controller. - 1 mark: Parallel transmission would be highly susceptible to crosstalk / skewing over 2 km and require expensive cabling. - 0.5 mark: Duplex transmission is unnecessary because bidirectional communication is not required for passive sensor logging.
Question 8 · Structured Explanation
4.5 marks
An automated greenhouse irrigation system is designed to keep soil moisture levels within a pre-set range. Explain how the sensors, microprocessor, and actuators work together in a continuous loop to manage the soil moisture.
Show answer & marking schemeHide answer & marking scheme
Worked solution
The automated system begins with the soil moisture sensors taking physical readings. These analog readings are converted to digital signals using an Analog-to-Digital Converter (ADC). The digital data is sent to the microprocessor, which continuously compares the incoming values against pre-stored optimal values. If the moisture is too low, the microprocessor outputs a control signal to an actuator (such as a motor or solenoid valve) to turn on the water. The system continuously samples and compares values, turning off the actuator once the moisture returns to the safe range.
Marking scheme
Award marks as follows (Max 4.5 marks): - 1 mark: Sensors continuously measure physical soil moisture levels and send analog signals. - 1 mark: Analog signals are converted to digital signals using an ADC (Analog-to-Digital Converter) so the microprocessor can read them. - 1 mark: The microprocessor compares the digital inputs against pre-set / target thresholds stored in its memory. - 1 mark: The microprocessor sends a command to an actuator (e.g., motor or valve) to open/close based on the comparison results. - 0.5 mark: Explicitly states that this process is executed in a continuous, endless loop.
Question 9 · Structured Explanation
4.5 marks
When a user types a website address such as 'www.example.com' into a web browser, a Domain Name System (DNS) lookup is performed. Explain how a DNS server is used to locate and load the requested webpage.
Show answer & marking schemeHide answer & marking scheme
Worked solution
The domain name typed by the user is sent by the browser to a local DNS server. The DNS server acts as an address book, mapping human-readable domain names to computer-friendly IP addresses. It searches its database; if it finds the IP address matching the domain, it returns it to the browser. If it is not found, the query is passed up to authoritative DNS servers. Once the browser receives the numerical IP address, it sends an HTTP/HTTPS request directly to the server at that IP address to fetch the webpage resources.
Marking scheme
Award marks as follows (Max 4.5 marks): - 1 mark: The browser queries the DNS server with the domain name / URL entered by the user. - 1 mark: The DNS server looks up the domain name in its database to find its matching IP address. - 1 mark: The DNS server returns the numerical IP address to the user's web browser. - 1 mark: The browser uses this IP address to establish communication and request webpage files directly from the hosting web server. - 0.5 mark: Note that if the local DNS server does not have the record, it queries other / recursive / authoritative DNS servers to resolve it.
Question 10 · Structured Explanation
4.5 marks
A company uses a firewall to secure its internal Local Area Network (LAN) connected to the Internet. Explain how a firewall acts as a security barrier to protect the LAN.
Show answer & marking schemeHide answer & marking scheme
Worked solution
A firewall sits between the company's internal LAN and the external Internet. It monitors all data packets entering and leaving the network. By comparing these packets against pre-configured security criteria (rules), the firewall decides whether to allow them through or block them. For instance, it can block incoming traffic from unrecognized IP addresses, prevent access to malicious websites, or block unauthorized protocols on specific ports. It also keeps logs of network activities to help identify intrusion attempts.
Marking scheme
Award marks as follows (Max 4.5 marks): - 1 mark: Monitors / filters both incoming and outgoing network traffic. - 1 mark: Uses a list of pre-defined security rules / criteria to permit or block data packets. - 1 mark: Blocks unauthorized external access attempts, hackers, or suspicious data packets from entering the LAN. - 1 mark: Can restrict access to specific protocols, ports, IP addresses, or domain names. - 0.5 mark: Keeps log files of traffic / flags unusual traffic spikes to alert the network administrator of potential attacks.
Question 11 · Structured Explanation
4.5 marks
Many modern laptops are built using Solid State Drives (SSD) instead of traditional Hard Disk Drives (HDD). Explain three physical or operational reasons why SSDs are more suitable for portable laptops than HDDs.
Show answer & marking schemeHide answer & marking scheme
Worked solution
SSDs are far superior for portable laptops due to their physical and operational architecture. First, SSDs contain no moving parts (unlike the spinning platters and read/write heads of HDDs), making them highly durable and resistant to physical damage when the laptop is bumped or dropped during travel. Second, because they use microchips instead of electric motors, they require significantly less power, extending the laptop's battery run-time. Third, SSD chips are much smaller and lighter than mechanical drives, allowing manufacturers to create lighter, more compact laptops.
Marking scheme
Award marks as follows (Max 4.5 marks): - Up to 1.5 marks (0.5 marks each) for identifying three distinct features of SSDs: - Feature 1: No moving parts. - Feature 2: Lower power consumption. - Feature 3: Lighter weight / smaller physical size (compactness). - (Accept: Faster read/write startup speeds as an operational feature). - Up to 3 marks (1 mark each) for linking each identified feature to its specific benefit for a portable laptop: - Explanation 1: No moving parts means it is shock-resistant and won't fail if the laptop is dropped or shaken during travel. - Explanation 2: Lower power consumption increases battery life, allowing the laptop to be used longer without a power source. - Explanation 3: Being lighter and smaller makes the laptop more portable, thinner, and easier to carry. - Explanation 4 (Alternative): Faster read/write speed means the system boots up and loads programs much quicker on the go.
Question 12 · Calculation & Table Completion
8 marks
An audio technician is preparing digital sound files for a local school's website.
(a) Calculate the file size of a 40-second mono audio recording with a sample rate of 12,000 Hz and a sample resolution of 16 bits. Show your working. Give your final answer in Kilobytes (KB), where 1 KB = 1,000 bytes. [3]
(b) Complete the table below by putting a tick (✓) to show whether each statement applies to MIDI, MP3, or WAV audio formats. Some statements may apply to more than one format. [5]
| Statement | MIDI | MP3 | WAV | |---|---|---|---| | Uses lossy compression to reduce file size | | | | | Stores individual instrumental notes and commands rather than actual audio waves | | | | | Contains raw, uncompressed audio data | | | | | Files are typically the largest of the three formats for the same duration of audio | | | | | Does not contain any vocal tracks or spoken words | | | |
Show answer & marking schemeHide answer & marking scheme
Worked solution
Part (a): 1. Identify the formula for audio file size: File Size (bits) = Sample Rate × Sample Resolution × Duration × Number of Channels 2. Substitute the given values into the formula: File Size = 12,000 Hz × 16 bits × 40 seconds × 1 channel 3. Perform the calculation: 12,000 × 16 = 192,000 192,000 × 40 = 7,680,000 bits 4. Convert bits to bytes (divide by 8): 7,680,000 / 8 = 960,000 bytes (Alternative: 16 bits = 2 bytes, so 12,000 × 2 × 40 = 960,000 bytes) 5. Convert bytes to Kilobytes (divide by 1,000 as specified): 960,000 / 1,000 = 960 KB
Part (b): - "Uses lossy compression to reduce file size": MP3 uses lossy compression (perceptual coding). - "Stores individual instrumental notes and commands...": MIDI contains performance data (pitch, volume, tempo) rather than actual audio recordings. - "Contains raw, uncompressed audio data": WAV typically stores raw, uncompressed PCM audio. - "Files are typically the largest...": WAV is uncompressed and therefore much larger than MIDI or MP3. - "Does not contain any vocal tracks...": MIDI only stores synthesizer and control commands; it cannot record vocals natively.
Marking scheme
Part (a) [3 Marks]: - 1 mark for showing correct formula setup: 12,000 × 16 × 40 (or 12,000 × 2 × 40). - 1 mark for correct intermediate calculation (e.g., 7,680,000 bits or 960,000 bytes). - 1 mark for correct final answer with units: 960 KB.
Part (b) [5 Marks]: - 1 mark for ticking 'MP3' for row 1. - 1 mark for ticking 'MIDI' for row 2. - 1 mark for ticking 'WAV' for row 3. - 1 mark for ticking 'WAV' for row 4. - 1 mark for ticking 'MIDI' for row 5.
Question 13 · Calculation & Table Completion
8 marks
Computers use different number systems to represent, process, and transmit digital data.
(a) Perform the binary addition of the following two 8-bit binary numbers: 01011100 + 00101011
Show your working. Convert your final 8-bit binary sum into its Hexadecimal equivalent. [4]
(b) Complete the table below by converting each value into its alternative representations. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Part (a): 1. Perform binary addition: Carries: 1 1 1 1 1 0 0 0 1 0 1 1 1 0 0 (92 in denary) + 0 0 1 0 1 0 1 1 (43 in denary) ----------------- 1 0 0 0 0 1 1 1 (135 in denary) 2. Convert 10000111 to Hexadecimal by splitting into two 4-bit nibbles: - Left nibble: 1000 = 8 - Right nibble: 0111 = 7 - Hexadecimal result = 87
Part (b): - For Denary 83: - Convert to Binary: 64 + 16 + 2 + 1 = 83, which is 01010011 (i). - Convert to Hexadecimal: Split 01010011 into 0101 (5) and 0011 (3), which is 53 (ii). - For Binary 10011100: - Convert to Denary: 128 + 16 + 8 + 4 = 156 (iii). - Convert to Hexadecimal: Split 10011100 into 1001 (9) and 1100 (12, which is C), which is 9C (iv).
Marking scheme
Part (a) [4 Marks]: - 1 mark for showing correct binary carry operations during addition. - 1 mark for correct binary addition result: 10000111. - 1 mark for showing method of splitting binary sum into nibbles to convert to hex. - 1 mark for correct final hexadecimal answer: 87 (or 0x87).
Part (b) [4 Marks]: - 1 mark for correct binary value (i): 01010011. - 1 mark for correct hexadecimal value (ii): 53. - 1 mark for correct denary value (iii): 156. - 1 mark for correct hexadecimal value (iv): 9C.
Paper 22: Algorithms, Programming and Logic
Answer all questions. Calculators must not be used. Total marks: 75. Questions require pseudocode construction, tracing, debugging, logic evaluation, databases, and structural modifications.
7 Question · 48 marks
Question 1 · Trace Tables & Diagrams
5 marks
A programmer has designed an algorithm to analyze sequences of identical numbers in an array. Complete the trace table for the given pseudocode algorithm.
Count <- 1 MaxRun <- 1 FOR i <- 2 TO 6 IF Numbers[i] = Numbers[i-1] THEN Count <- Count + 1 ELSE IF Count > MaxRun THEN MaxRun <- Count ENDIF Count <- 1 ENDIF NEXT i IF Count > MaxRun THEN MaxRun <- Count ENDIF OUTPUT MaxRun
Complete the trace table below: iNumbers[i]Numbers[i-1]CountMaxRunOutput 11
Show answer & marking schemeHide answer & marking scheme
Worked solution
Step-by-step trace of the pseudocode execution: 1. Initial state: Count = 1, MaxRun = 1. 2. i = 2: Numbers[2] (4) equals Numbers[1] (4). Condition is TRUE. Count increments to 2. 3. i = 3: Numbers[3] (7) does not equal Numbers[2] (4). Condition is FALSE. Count (2) > MaxRun (1) is TRUE, so MaxRun becomes 2. Count resets to 1. 4. i = 4: Numbers[4] (7) equals Numbers[3] (7). Condition is TRUE. Count increments to 2. 5. i = 5: Numbers[5] (7) equals Numbers[4] (7). Condition is TRUE. Count increments to 3. 6. i = 6: Numbers[6] (2) does not equal Numbers[5] (7). Condition is FALSE. Count (3) > MaxRun (2) is TRUE, so MaxRun becomes 3. Count resets to 1. 7. Post-loop: Count (1) > MaxRun (3) is FALSE. Output is MaxRun, which is 3.
Marking scheme
Award 1 mark for each of the following (up to 5 marks total): - 1 mark: Correct values of loop variable 'i' (sequentially tracking 2, 3, 4, 5, 6). - 1 mark: Correct intermediate values of 'Count' (2, then 1, then 2, then 3, then 1). - 1 mark: Correct update of 'MaxRun' to 2 when i = 3. - 1 mark: Correct update of 'MaxRun' to 3 when i = 6. - 1 mark: Correct final output value of 3.
Question 2 · Trace Tables & Diagrams
5 marks
Trace the following pseudocode algorithm which extracts, reverses, and counts even digits of a denary integer. Complete the trace table provided below.
Num <- 384 Reverse <- 0 EvenCount <- 0 WHILE Num > 0 DO Digit <- Num MOD 10 Reverse <- (Reverse * 10) + Digit IF (Digit MOD 2) = 0 THEN EvenCount <- EvenCount + 1 ENDIF Num <- Num DIV 10 ENDWHILE OUTPUT Reverse, EvenCount
Complete the trace table: NumReverseEvenCountDigitOutput38400
Show answer & marking schemeHide answer & marking scheme
Worked solution
Detailed step-by-step tracing of the loop execution: 1. Initial values: Num = 384, Reverse = 0, EvenCount = 0. 2. Loop Iteration 1 (Num > 0 is true): - Digit = 384 MOD 10 = 4. - Reverse = (0 * 10) + 4 = 4. - Digit MOD 2 = 0 is true, so EvenCount = 1. - Num = 384 DIV 10 = 38. 3. Loop Iteration 2 (Num > 0 is true): - Digit = 38 MOD 10 = 8. - Reverse = (4 * 10) + 8 = 48. - Digit MOD 2 = 0 is true, so EvenCount = 2. - Num = 38 DIV 10 = 3. 4. Loop Iteration 3 (Num > 0 is true): - Digit = 3 MOD 10 = 3. - Reverse = (48 * 10) + 3 = 483. - Digit MOD 2 = 0 is false, so EvenCount remains 2. - Num = 3 DIV 10 = 0. 5. Loop Terminated (Num > 0 is false). 6. Output: 483, 2.
Marking scheme
Award marks as follows (total 5 marks): - 1 mark: Correct trace of 'Digit' values (4, 8, 3 in correct sequence). - 1 mark: Correct updates of 'Reverse' column (4, 48, 483). - 1 mark: Correct updates of 'EvenCount' (1, 2). - 1 mark: Correct sequence of 'Num' division updates (38, 3, 0). - 1 mark: Correct final output displayed as '483, 2'.
Question 3 · Trace Tables & Diagrams
5 marks
A logic circuit with inputs A, B, and C generates intermediate signals P and Q, and a final output X. The logical behavior is described below: - P is the output of an AND gate with inputs A and NOT B. - Q is the output of an XOR gate with inputs B and C. - X is the output of an OR gate with inputs P and Q.
Complete the truth table below: ABCPQX000 001 010 011 100 101 110 111
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let us evaluate the output for each gate step-by-step: - P = A AND (NOT B): - P is 1 only when A = 1 and B = 0. This occurs in rows 5 and 6. - For all other rows, P = 0. - Q = B XOR C: - Q is 1 when B and C have different logic states (one is 1, the other is 0). - This occurs in rows 2, 3, 6, and 7. For other rows, Q = 0. - X = P OR Q: - X is 1 if either P = 1, Q = 1, or both are 1. - Row 1: 0 OR 0 = 0 - Row 2: 0 OR 1 = 1 - Row 3: 0 OR 1 = 1 - Row 4: 0 OR 0 = 0 - Row 5: 1 OR 0 = 1 - Row 6: 1 OR 1 = 1 - Row 7: 0 OR 1 = 1 - Row 8: 0 OR 0 = 0
Marking scheme
Award marks as follows (total 5 marks): - 1 mark: Correct P column values (0, 0, 0, 0, 1, 1, 0, 0). - 2 marks: Correct Q column values (0, 1, 1, 0, 0, 1, 1, 0). Deduct 1 mark if 1 or 2 errors are made; 0 marks for 3 or more errors. - 2 marks: Correct X column values (0, 1, 1, 0, 1, 1, 1, 0). Deduct 1 mark if 1 or 2 errors are made. Allow follow-through logic based on candidate's P and Q columns.
Question 4 · Structured
6 marks
A garden nursery uses a database table named PLANTS to store inventory records. The database schema has the following fields:
- `PlantID` (Primary key, e.g. 'P204') - `CommonName` (Text) - `Category` (Text, e.g. 'Shrub', 'Tree', 'Flower') - `Price` (Real/Currency, e.g. 19.99) - `InStock` (Integer) - `Evergreen` (Boolean, TRUE/FALSE)
(a) Write an SQL query to display the `CommonName`, `Price`, and `InStock` of all plants that are in the 'Shrub' or 'Tree' category, have a price of less than 20.00, and are evergreen. [4 marks]
(b) Explain why `PlantID` is a suitable choice for the primary key in this table. [2 marks]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) ```sql SELECT CommonName, Price, InStock FROM PLANTS WHERE (Category = 'Shrub' OR Category = 'Tree') AND Price < 20.00 AND Evergreen = TRUE; ``` (Note: Accepting syntax variations like `Evergreen = True` or omitting `TRUE` as `Evergreen` is a boolean, and variations of quotes around text values like "Shrub").
(b) - A primary key uniquely identifies each record in the table. - Each plant variety will have a distinct `PlantID` (no two rows can have the same ID), ensuring no duplication of records.
Marking scheme
(a) [4 marks] - 1 mark: Correct `SELECT` clause listing only `CommonName`, `Price`, and `InStock` separated by commas. - 1 mark: Correct `FROM PLANTS` clause. - 1 mark: Correct boolean logic for category: `(Category = 'Shrub' OR Category = 'Tree')` (must include parentheses or logically equivalent construct to ensure correct precedence). - 1 mark: Correct comparison logic for price and evergreen: `Price < 20.00 AND Evergreen = TRUE` (or `Evergreen = True` or `Evergreen`). All conditions must be correctly joined by AND.
(b) [2 marks] - 1 mark: State that a primary key must uniquely identify each record (row) in the table. - 1 mark: Explain that each plant will have its own unique `PlantID` (preventing duplicates / guaranteeing uniqueness).
Question 5 · Structured
6 marks
An airport database uses a table named FLIGHTS to track daily scheduled flights.
(a) Complete the table below by stating the most appropriate database data type for each of the given fields: [3 marks]
| Field Name | Description | Data Type | | :--- | :--- | :--- | | `FlightNumber` | e.g. 'AA340' or 'LH1982' | | | `Capacity` | Total passenger capacity of the aircraft, e.g. 180 | | | `Delayed` | Whether the flight is delayed or on-time (Yes/No) | |
(b) Write an SQL query to retrieve the `FlightNumber` and `Destination` for all flights in the `FLIGHTS` table where the capacity is greater than 150 and the flight is delayed (`Delayed` is TRUE). [3 marks]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) - `FlightNumber`: Text / Alphanumeric / String (It contains both letters and numbers, so arithmetic is not performed on it). - `Capacity`: Integer / Whole Number (A whole number representing count of passengers). - `Delayed`: Boolean / Yes/No (A binary state indicating whether the flight is delayed or not).
(b) ```sql SELECT FlightNumber, Destination FROM FLIGHTS WHERE Capacity > 150 AND Delayed = TRUE; ``` (Note: `Delayed = True` or simply `Delayed` are acceptable variations).
Marking scheme
(a) [3 marks] - 1 mark: Text / Alphanumeric / String for `FlightNumber` - 1 mark: Integer / Whole Number for `Capacity` - 1 mark: Boolean / Yes/No / Logical for `Delayed`
(b) [3 marks] - 1 mark: Correct `SELECT FlightNumber, Destination FROM FLIGHTS` - 1 mark: Correct criteria for capacity: `Capacity > 150` - 1 mark: Correct criteria for delay: `AND Delayed = TRUE` (or `AND Delayed` or `AND Delayed = Yes` depending on database context)
Question 6 · Structured
6 marks
A student database contains a table named `STUDENTS` with the following fields: - `StudentID` (Text, Primary Key) - `FirstName` (Text) - `LastName` (Text) - `ClassCode` (Text) - `Score` (Integer)
A programmer wrote the following SQL query to display the `FirstName`, `LastName`, and `Score` of all students in ClassCode 'CS101' who scored more than 80 marks, sorted from the highest score to the lowest score:
```sql SELECT FirstName, LastName, Score, ClassCode FROM STUDENTS WHERE ClassCode IS CS101 AND Score >= 80 ORDER BY Score ASC; ```
(a) Identify three errors in this SQL query. [3 marks]
(b) Write the corrected SQL query to meet the programmer's requirement. [3 marks]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) Three of the following errors should be identified: - Error 1: The `SELECT` list unnecessarily includes `ClassCode` (the specification only asked to display `FirstName`, `LastName`, and `Score`). - Error 2: `ClassCode IS CS101` uses `IS` instead of `=` and/or is missing quotes around the string literal `'CS101'`. - Error 3: `Score >= 80` is incorrect because the requirement is "scored more than 80" (should be `Score > 80`). - Error 4: `ORDER BY Score ASC` sorts the scores in ascending order, but they should be sorted from highest to lowest (which requires `ORDER BY Score DESC`).
(b) ```sql SELECT FirstName, LastName, Score FROM STUDENTS WHERE ClassCode = 'CS101' AND Score > 80 ORDER BY Score DESC; ```
Marking scheme
(a) [3 marks] - 1 mark for each valid error identified (up to 3 max): - Identified that `ClassCode` should not be selected / in the `SELECT` clause. - Identified that `ClassCode IS CS101` needs `=` instead of `IS` OR identified that `'CS101'` must be enclosed in single/double quotes. - Identified that `>= 80` should be `> 80` (strictly greater than). - Identified that `ORDER BY Score ASC` should be `DESC` (for descending/highest to lowest order).
(b) [3 marks] - 1 mark: Correct `SELECT FirstName, LastName, Score FROM STUDENTS` (no ClassCode in select list). - 1 mark: Correct WHERE clause condition: `WHERE ClassCode = 'CS101' AND Score > 80` (allow double quotes around "CS101"). - 1 mark: Correct ordering: `ORDER BY Score DESC` (or `ORDER BY Score DESCENDING`).
Question 7 · Detailed Pseudocode Task
15 marks
A drone delivery company operates 30 drones, uniquely numbered from 1 to 30. Write an algorithm using pseudocode to manage their status and track their total deliveries.
The algorithm must use three global 1D arrays, each containing 30 elements: - DroneID: stores the integers 1 to 30 - DroneStatus: stores the current status of each drone as a string (initially all set to "Idle") - TotalDeliveries: stores the number of deliveries completed by each drone (initially all set to 0)
The program must perform the following tasks: 1. Initialize all three arrays. 2. Allow a user to repeatedly select one of three options until they input -1 to quit: - Option 1 (Dispatch): Input a Drone ID. If the ID is valid (1 to 30) and its status is "Idle", change its status to "Active". Otherwise, output an appropriate error message. - Option 2 (Return): Input a Drone ID. If the ID is valid and its status is "Active", change its status to "Idle" and increment its count in TotalDeliveries by 1. Otherwise, output an appropriate error message. - Option -1: Terminate the user selection process. 3. After the user terminates the process: - Count and output the total number of currently "Active" drones. - Find and output the ID of the drone that has completed the highest number of deliveries, along with its delivery count. (If there is a tie, outputting any of the tied drones is acceptable).
Show answer & marking schemeHide answer & marking scheme
Worked solution
The solution involves writing a fully structured pseudocode algorithm. It is split into three main parts: 1. Array Initialization: Using a FOR loop running from 1 to 30 to assign sequential values to DroneID, 'Idle' to DroneStatus, and 0 to TotalDeliveries. 2. Iterative Process Control: A REPEAT-UNTIL or WHILE loop controlled by checking if user input is not -1. Inside this, nested IF statements validate user actions (Dispatch vs. Return), range-check input IDs (1 to 30), verify current drone states before changing them, update appropriate arrays, and produce clean error messages. 3. Summary Calculations: A sequential loop through the arrays to sum instances of 'Active' statuses, and a standard linear search algorithm initialized with the first elements to find the index containing the highest value in the TotalDeliveries array. The outputs are presented clearly.
Marking scheme
Award marks based on the following criteria (Max 15 marks):
- Array Initialization (2 marks): * 1 mark: Using a FOR loop from 1 to 30 to initialize arrays. * 1 mark: Initializing all three arrays with correct corresponding types (DroneID = Index, DroneStatus = "Idle", TotalDeliveries = 0).
- Loop Structure (2 marks): * 1 mark: An outer loop (REPEAT/UNTIL or WHILE) that correctly repeats until -1 is input. * 1 mark: Prompting and taking inputs within the loop correctly.
- Selection Logic & Validation (5 marks): * 1 mark: Correct conditions separating Choice 1, Choice 2, and others. * 1 mark: Checking that entered Drone ID is within boundary limits (1 to 30 inclusive). * 1 mark: Validating drone is "Idle" before Dispatch and "Active" before Return. * 1 mark: Setting drone status correctly to "Active" (Dispatch) or "Idle" (Return). * 1 mark: Correctly outputting appropriate error messages when validation checks fail.
- Delivery Incrementation (1 mark): * 1 mark: Incrementing TotalDeliveries array count by 1 for the correct drone ID upon successful return.
- Final Calculations & Outputs (5 marks): * 1 mark: Initializing and correctly counting currently "Active" drones using a loop. * 1 mark: Outputting the total active drone count outside the main loop. * 1 mark: Correct algorithm to search for the highest delivery count (initializing max with first element and looping remaining elements). * 1 mark: Correctly storing and locating the matching Drone ID with the highest delivery count. * 1 mark: Outputting both the drone ID and its delivery count clearly.
Wondering how well you actually know this?
Thinka is an AI practice app for DSE students — unlimited questions, instant auto-marking, and detailed step-by-step solutions. 100,000+ students use it to confirm they actually know it, not just think they do.