Cambridge IGCSE · thinka 原創模擬試題

2026 Cambridge IGCSE Computer Science (0478) 模擬試題連答案詳解

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

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

卷一: Computer Systems

Answer all questions. Calculators are not permitted.
24 題目 · 61.360000000000014 分
題目 1 · 選擇題
1 分
A digital thermometer uses an 8-bit register to store temperature values in two's complement form.

What is the denary value represented by the 8-bit binary pattern 11010110?
  1. A.-42
  2. B.-86
  3. C.-106
  4. D.214
查看答案詳解

解題

In 8-bit two's complement, the most significant bit (MSB) has a weight of -128, while the remaining bits have positive place values (64, 32, 16, 8, 4, 2, 1).

11010110 = (-128 * 1) + (64 * 1) + (32 * 0) + (16 * 1) + (8 * 0) + (4 * 1) + (2 * 1) + (1 * 0)
= -128 + 64 + 16 + 4 + 2
= -128 + 86
= -42

Alternatively, invert all bits (00101001 = 41) and add 1 (00101010 = 42), giving -42.

評分準則

1 mark for A (-42).

Accept: A only.
題目 2 · 選擇題
1 分
Which statement correctly describes how an Automatic Repeat reQuest (ARQ) protocol operates to ensure error-free data transmission?
  1. A.The receiving device generates a check digit and inverts any corrupted bit without contacting the sender.
  2. B.If the sender does not receive an acknowledgement before a predefined timeout occurs, it automatically retransmits the data packet.
  3. C.The sender transmits each packet twice simultaneously and compares the return signals.
  4. D.A parity block is generated at the destination to permanently decrypt corrupted payload data.
查看答案詳解

解題

ARQ uses acknowledgements (positive/negative) and timeouts. If the sender receives a negative acknowledgement (NAK) or does not receive an acknowledgement within a specified timeout limit, the packet is automatically retransmitted.

評分準則

1 mark for B.

Accept: B only.
題目 3 · 選擇題
1 分
During the fetch stage of the Fetch–Decode–Execute (FDE) cycle in a Von Neumann CPU, which event occurs immediately after the address in the Program Counter (PC) is copied to the Memory Address Register (MAR)?
  1. A.The Program Counter (PC) is incremented by 1.
  2. B.The Current Instruction Register (CIR) executes the opcode.
  3. C.The Accumulator (ACC) clears its existing numerical contents.
  4. D.The Arithmetic Logic Unit (ALU) calculates the next logical address.
查看答案詳解

解題

In the standard fetch sequence: (1) PC contents are copied to MAR; (2) The PC is incremented by 1 so it points to the next instruction; (3) The instruction at the address in MAR is fetched across the data bus into MDR; (4) The instruction is copied from MDR to CIR.

評分準則

1 mark for A.

Accept: A only.
題目 4 · 選擇題
1 分
An employee receives an email claiming to be from the IT support team, warning that their mailbox is full and providing a hyperlink to a fake login portal to expand storage. When entered, the login credentials are stolen.

Which type of cyber security threat is being described?
  1. A.Pharming
  2. B.Phishing
  3. C.Ransomware
  4. D.Brute-force attack
查看答案詳解

解題

Phishing involves sending legitimate-looking emails containing links to fake websites designed to trick users into disclosing sensitive information such as usernames and passwords.

評分準則

1 mark for B.

Accept: B only.
題目 5 · short_answer
2 分
A temperature sensor in a refrigerated delivery van stores its reading as an 8-bit two's complement binary integer:

`10110100`

Convert this 8-bit two's complement binary integer into its denary value. Show your working.
查看答案詳解

解題

Method 1 (Place values):
Place values for an 8-bit two's complement integer are: \(-128, 64, 32, 16, 8, 4, 2, 1\).
\(-128 \times 1 + 64 \times 0 + 32 \times 1 + 16 \times 1 + 8 \times 0 + 4 \times 1 + 2 \times 0 + 1 \times 0\)
\(= -128 + 32 + 16 + 4 = -76\)

Method 2 (Invert and add 1):
Invert bits of `10110100` \(\rightarrow\) `01001011`
Add 1 \(\rightarrow\) `01001100`
Convert `01001100` to denary: \(64 + 8 + 4 = 76\)
Apply negative sign: \(-76\)

評分準則

1 mark for correct method / working shown (e.g. \(-128 + 32 + 16 + 4\) OR inverting bits to `01001011` and adding 1 to get \(76\))
1 mark for correct final denary value: \(-76\)
題目 6 · short_answer
2 分
A diagnostic tool on a robotic assembly line outputs the error code `B7` in hexadecimal.

(a) Convert the hexadecimal value `B7` into an 8-bit binary number.
(b) Convert the hexadecimal value `B7` into a denary number.
查看答案詳解

解題

(a) Hexadecimal digit \(\text{B} = 11 = 1011_2\), digit \(7 = 0111_2\).
Combining nibbles: `10110111`

(b) \(\text{B7}_{16} = (11 \times 16) + 7 = 176 + 7 = 183\)
(or from binary: \(128 + 32 + 16 + 4 + 2 + 1 = 183\))

評分準則

(a) 1 mark for correct 8-bit binary representation: `10110111`
(b) 1 mark for correct denary integer: `183`
題目 7 · short_answer
2 分
Data is transmitted across a network in discrete packets. Identify two items of data that are stored in the packet header.
查看答案詳解

解題

The packet header contains control data needed to route and reassemble the packet, including:
- IP address of the destination
- IP address of the sender / source
- Sequence / packet number
- Packet size

評分準則

1 mark per valid item (max 2):
- Destination (IP / MAC) address
- Source / sender / originator (IP / MAC) address
- Packet / sequence number // packet order identifier
- Packet size / length
- Protocol type

Do not accept: payload, data itself, checksum / trailer items.
題目 8 · short_answer
2 分
Explain the role of the Program Counter (PC) during the fetch stage of the fetch-decode-execute cycle.
查看答案詳解

解題

During the fetch stage, the Program Counter (PC) stores the address of the next instruction to be fetched from memory. This address is copied to the Memory Address Register (MAR), and the PC is then incremented by 1 to point to the memory address of the subsequent instruction.

評分準則

1 mark per linked point (max 2):
- Holds / stores the (memory) address of the next instruction to be fetched / executed
- Copies / sends this address to the Memory Address Register (MAR)
- Increments (by 1) to point to the address of the following instruction
題目 9 · short_answer
2 分
A field biologist uses a portable data-logging unit in harsh outdoor conditions. Give two reasons why solid-state storage (SSD) is more suitable than a magnetic hard disk drive (HDD) for this device.
查看答案詳解

解題

Solid-state storage uses flash memory and contains no moving parts, making it far more robust and shock-resistant against drops, bumps, and vibrations compared to magnetic HDDs. It also has lower power consumption, which is critical for prolonging the battery life of portable field devices.

評分準則

1 mark per valid reason (max 2):
- No moving parts // less susceptible to physical shock / vibration / drops // more durable / robust
- Consumes less power // prolongs battery life
- Lighter in weight // more portable / compact
- Faster read / write access speeds
- Generates less heat
- Silent operation

Do not accept: cheaper (SSD is generally more expensive per GB).
題目 10 · short_answer
2 分
State two differences between a compiler and an interpreter regarding how they translate source code and report errors.
查看答案詳解

解題

1. Translation: A compiler translates the entire high-level program at once to produce an independent executable file, whereas an interpreter translates and executes source code line-by-line.
2. Error reporting: A compiler reports all syntax errors in an error list after scanning the entire program, whereas an interpreter halts execution immediately upon encountering an error and identifies that specific line.

評分準則

1 mark per valid distinction (max 2):
- Compiler translates the whole program at once // Interpreter translates code line-by-line / one instruction at a time
- Compiler creates an executable file / object code // Interpreter does not produce an executable file (must interpret code each time it runs)
- Compiler generates an error report / list after scanning all code // Interpreter stops execution as soon as the first error is encountered
- Compiled code executes faster once translated // Interpreted code executes slower as translation occurs during runtime
題目 11 · short_answer
2 分
Describe two ways in which a proxy server helps protect an organisation's local computer network.
查看答案詳解

解題

A proxy server acts as an intermediary between client devices and the internet. It hides the internal IP addresses of client machines so they are not directly exposed to external threats, and it inspects inbound and outbound traffic to filter content, blocking access to unauthorized or malicious websites.

評分準則

1 mark per valid function / protection mechanism (max 2):
- Hides / masks the internal (client) IP address(es) from external servers / internet
- Acts as a firewall / filters incoming and outgoing web traffic
- Blocks access to unauthorised / blacklisted / malicious websites
- Caches frequently accessed web pages to reduce external bandwidth and handle DDoS attacks
- Logs internet traffic / user activity to detect suspicious network behaviour
題目 12 · short_answer
2 分
An automated irrigation system maintains optimal moisture levels for crops in an agricultural greenhouse.

(a) Identify the most suitable sensor used to monitor the ground conditions.
(b) Identify the output component used to physically open and close the irrigation water valve.
查看答案詳解

解題

(a) A moisture sensor (or soil humidity sensor) directly measures the water content in the soil.
(b) An actuator is the output device that converts an electrical control signal from the microprocessor into mechanical motion to physically turn/open/close the water valve.

評分準則

(a) 1 mark for: moisture sensor // humidity sensor // soil moisture sensor
(b) 1 mark for: actuator // motor (controlling the valve)
題目 13 · short_answer
2 分
A microcontroller in a refrigeration unit stores an offset temperature value as an 8-bit two's complement binary integer:

$$\text{10101100}$$

Convert the 8-bit two's complement binary integer $\text{10101100}$ into denary. Show your working.
查看答案詳解

解題

Method 1 (Place value method):
Place values for 8-bit two's complement: $-128, 64, 32, 16, 8, 4, 2, 1$
$(-128 \times 1) + (32 \times 1) + (8 \times 1) + (4 \times 1)$
$= -128 + 32 + 8 + 4$
$= -84$

Method 2 (Invert and add 1):
1. Invert the bits: $01010011$
2. Add 1: $01010011 + 1 = 01010100$
3. Convert to denary: $64 + 16 + 4 = 84$
4. Apply negative sign: $-84$

評分準則

1 mark for valid working showing correct place values (e.g. $-128 + 32 + 8 + 4$) OR inverting bits and adding 1 to obtain magnitude $84$.
1 mark for correct final answer: $-84$.
題目 14 · short_answer
2 分
A digital camera stores an uncompressed image file with a size of $24\text{ MiB}$.

Calculate the size of this image file in $\text{KiB}$. Show your working.
查看答案詳解

解題

To convert mebibytes ($\text{MiB}$) to kibibytes ($\text{KiB}$), multiply by $1024$:
$$\text{File size} = 24 \times 1024 = 24576\text{ KiB}$$

評分準則

1 mark for showing multiplication by $1024$ (e.g. $24 \times 1024$).
1 mark for the correct final answer: $24576$ ($\text{KiB}$).
題目 15 · Structured Descriptive & Explanatory
3.67 分
A weather monitoring station records daily temperature anomalies as 8-bit signed binary integers using two's complement representation.

(a) Convert the denary value \(-43\) into an 8-bit two's complement binary integer. Show your working.

(b) The station's register currently stores the 8-bit binary value `11010100`.
Perform a logical right shift of two places on this binary value and explain the effect this operation has on the original unsigned value.
查看答案詳解

解題

(a) Step 1: Represent positive denary 43 in 8-bit binary:
\(43 = 32 + 8 + 2 + 1 = 00101011_2\)
Step 2: Invert all bits (one's complement):
\(11010100_2\)
Step 3: Add 1 to get two's complement:
\(11010100 + 1 = 11010101_2\)

(b) Performing a logical right shift of 2 places on `11010100`:
- Shift all bits right by 2 positions, filling the most significant bits with 0s:
`00110100` -> `00110101` (last two bits `00` discarded).
- Effect on unsigned value: Shifting right by 2 places divides the denary value by \(2^2 = 4\) (integer division).

評分準則

(a) 2 marks total:
- 1 mark for correct method (e.g. converting 43 to binary `00101011` and inverting bits `11010100` // showing binary place values)
- 1 mark for correct final binary representation: `11010101`

(b) 2 marks total:
- 1 mark for correct shifted binary pattern: `00110101`
- 1 mark for explaining that a logical right shift of 2 places divides the number by 4 // integer division by 4 // discards least significant bits.
題目 16 · Structured Descriptive & Explanatory
3.67 分
A user downloads a high-definition video file from a web server over the internet.

(a) Explain how packet switching is used to transmit the video file from the web server to the user's computer.

(b) State two items of data contained in the header of an individual packet.
查看答案詳解

解題

(a) Packet switching operates through several stages:
1. The original video data is split into small units called packets.
2. Each packet travels independently across the network; individual packets may take different routes depending on network traffic and router decisions.
3. Routers read the destination IP address in the header to forward each packet along the optimal path.
4. Once all packets reach the destination, they are checked for errors and reassembled into the correct order based on their packet numbers.

(b) Packet headers typically contain:
- Destination IP address
- Source / sender IP address
- Sequence / packet number
- Packet size / length

評分準則

(a) Max 3 marks for:
- Data/file is broken down into small units / packets [1]
- Each packet travels independently across the network / can take different routes [1]
- Routers determine the route for each packet based on destination address [1]
- Packets are reordered / reassembled at the destination using sequence numbers [1]

(b) Max 1 mark (1 mark for both or 1 mark for any two correct items):
- Destination (IP) address [1]
- Source / Sender (IP) address [1]
- Packet sequence number / sequence ID [1]
- Packet size / total number of packets [1]
題目 17 · Structured Descriptive & Explanatory
3.67 分
A central processing unit (CPU) operates using the Von Neumann architecture.

(a) Describe the specific role of the Memory Address Register (MAR) and the Memory Data Register (MDR) during the fetch stage of the fetch-decode-execute (FDE) cycle.

(b) Explain how increasing the cache size improves the performance of the CPU.
查看答案詳解

解題

(a) In the fetch stage:
1. The Memory Address Register (MAR) holds the memory address currently being read from (copied from the Program Counter).
2. The Memory Data Register (MDR) holds the contents (data or instruction) read from the address in RAM, which is transferred across the data bus.

(b) Cache memory is situated directly on or very close to the CPU chip and has much faster access speeds than main memory (RAM). A larger cache allows a larger volume of frequently accessed instructions and data to be retained. This reduces the time the CPU spends waiting for data from RAM, thereby increasing execution speed.

評分準則

(a) 2 marks:
- 1 mark: MAR holds the address of the memory location being read from / accessed / written to.
- 1 mark: MDR stores the data / instruction fetched from RAM // stores data waiting to be written to RAM.

(b) 2 marks:
- 1 mark: Cache stores frequently / recently used instructions and data.
- 1 mark: Cache operates at much higher speeds than RAM ...
- 1 mark: ... therefore fewer read/write cycles to RAM are needed, reducing CPU idle / waiting time.
(Max 2 marks for part b)
題目 18 · Structured Descriptive & Explanatory
3.67 分
An operating system manages hardware, software, and user interactions.

(a) Explain how an interrupt is generated and handled by the operating system when a user sends a print job to an offline printer.

(b) Identify two other core management functions carried out by an operating system.
查看答案詳解

解題

(a) Process of generating and handling an interrupt:
1. The peripheral device/hardware generates an interrupt signal and transmits it to the CPU.
2. The CPU finishes its current fetch-decode-execute cycle and checks interrupt priority.
3. The CPU saves the contents of its current registers / state to a stack.
4. The CPU calls and executes the appropriate Interrupt Service Routine (ISR) to process the condition (e.g., displaying 'Printer Offline' error message).
5. Once handled, the saved register states are restored, and the CPU resumes executing the interrupted program.

(b) Other key functions of an OS include:
- Memory management (allocating RAM to active programs)
- File management (directory structure, file permissions)
- Multitasking / process scheduling
- Device management (drivers for hardware peripherals)
- User access / security management

評分準則

(a) Max 3 marks:
- Hardware / peripheral generates and sends an interrupt signal to the CPU [1]
- Current CPU state / register values are saved / pushed onto a stack [1]
- The CPU executes the specific Interrupt Service Routine (ISR) / interrupt handler [1]
- The saved state is restored and the original process resumes [1]

(b) 1 mark for any two valid functions (0.5 mark each / 1 mark for two):
- File management // Memory management // Multitasking / process scheduling // Peripheral / device management // User management / security // Providing a user interface.
題目 19 · Structured Descriptive & Explanatory
3.67 分
A student types the Uniform Resource Locator (URL) `https://www.example.org/index.html` into a web browser.

(a) Identify the three main components of this URL.

(b) Describe the role of the Domain Name System (DNS) in retrieving the requested web page.
查看答案詳解

解題

(a) Breakdown of the URL:
- Protocol: `https` (Hypertext Transfer Protocol Secure)
- Domain name / Hostname: `www.example.org`
- File name / Path: `index.html`

(b) Role of DNS:
1. The browser queries a DNS server with the domain name `www.example.org`.
2. The DNS server looks up the domain name in its records to find the corresponding numerical IP address.
3. The DNS server sends this IP address back to the user's browser.
4. If the local DNS server does not have the record, it queries higher-level domain servers until the IP address is resolved.

評分準則

(a) 2 marks:
- 1 mark for identifying protocol (`https`) and domain name (`www.example.org`)
- 1 mark for identifying file name / resource path (`index.html`)

(b) 2 marks:
- 1 mark: DNS stores a database of domain names and their matching IP addresses.
- 1 mark: DNS resolves / translates the domain name into an IP address and sends it back to the browser / client.
題目 20 · Structured Descriptive & Explanatory
3.67 分
An online retail organisation wants to protect its customer data against cyber threats.

(a) Distinguish between phishing and pharming.

(b) Explain how the use of a proxy server enhances the security of the organisation's internal network.
查看答案詳解

解題

(a) Distinction:
- Phishing: Relies on social engineering; uses deceptive emails/messages containing links that trick users into navigating to spoofed websites and entering sensitive details.
- Pharming: Technical attack without requiring the user to click a link; modifies DNS settings or host files to automatically redirect requests for legitimate URLs to fraudulent websites.

(b) Role of a proxy server:
- Acts as a gateway / buffer between the local private network and public internet.
- Hides internal IP addresses of computers, making them invisible to potential external attackers.
- Can inspect and filter web requests/traffic against firewall rules to prevent malware downloads or data exfiltration.
- Can cache web pages to improve access speeds and reduce external bandwidth.

評分準則

(a) 2 marks:
- 1 mark for phishing: Deceptive email / message sent to trick a user into clicking a link / revealing personal credentials.
- 1 mark for pharming: Malicious code redirects traffic to a bogus website / manipulates DNS records without the user's knowledge.

(b) 2 marks:
- 1 mark: Acts as an intermediary / buffer between internal network and internet // conceals internal private IP addresses.
- 1 mark: Filters incoming/outgoing web traffic / blocks unauthorized websites / inspects content for malicious data.
題目 21 · Structured Descriptive & Explanatory
3.67 分
A commercial greenhouse uses an automated system to maintain optimal growing conditions for plants.

(a) Identify two sensors suitable for this automated system and describe the physical property each sensor measures.

(b) Explain how the microprocessor, sensors, and actuators interact in a closed-loop system to regulate the temperature inside the greenhouse.
查看答案詳解

解題

(a) Examples of suitable sensors:
1. Temperature sensor: measures ambient temperature / thermal energy.
2. Humidity sensor: measures the concentration of water vapour in the air.
(Other acceptable: Light sensor measuring illuminance, Soil moisture sensor measuring water content in soil).

(b) Feedback loop operation:
1. Sensors continuously measure environmental variables and send analogue data.
2. An Analogue-to-Digital Converter (ADC) converts the analogue signals into digital values readable by the microprocessor.
3. The microprocessor compares the digital readings against pre-programmed threshold parameters.
4. If the value falls outside acceptable limits (e.g., temperature is too high), the microprocessor sends a control signal to an actuator (e.g., motor to open vents / turn on fan).
5. If within limits, no action is taken.
6. The process loops continuously to maintain constant conditions.

評分準則

(a) 1 mark for two valid sensors with matching physical properties (0.5 each):
- Temperature sensor (temperature / heat) [1]
- Humidity sensor (air moisture / water vapour) [1]
- Light / light intensity sensor (ambient light level) [1]
- Soil moisture sensor (soil water level) [1]

(b) Max 3 marks for:
- Sensor sends data to microprocessor (converted via ADC if analogue noted) [1]
- Microprocessor compares current readings with stored / preset threshold values [1]
- If reading is outside range, microprocessor sends a signal to an actuator (e.g., heater / vent motor) [1]
- Process repeats in a continuous loop [1]
題目 22 · Structured Descriptive & Explanatory
3.67 分
A digital media developer creates an educational application containing audio narration and vector graphics.

(a) Explain what is meant by sound sampling, with reference to sample rate and sample resolution.

(b) Describe one advantage and one disadvantage of using lossy compression rather than lossless compression when storing the audio recordings.
查看答案詳解

解題

(a) Sound sampling details:
- Analogue sound is continuous; to convert it to digital format, the sound wave's amplitude is measured at fixed intervals.
- Sample rate refers to how many sample measurements are captured per second (e.g., 44.1 kHz = 44,100 samples per second).
- Sample resolution (bit depth) refers to the number of binary bits used to represent the amplitude of each individual sample.

(b) Lossy vs Lossless:
- Advantage of lossy: Achieves a substantially higher compression ratio / much smaller file size compared to lossless, meaning files upload/download faster and take up less storage space.
- Disadvantage of lossy: Discards data permanently (e.g., frequencies inaudible or less noticeable to human hearing), resulting in a slight drop in audio quality that cannot be recovered.

評分準則

(a) 2 marks:
- 1 mark: Sound sampling is measuring the amplitude of continuous analogue sound waves at regular time intervals.
- 1 mark: Sample rate is the number of samples recorded per second AND sample resolution is the number of bits used per sample.

(b) 2 marks:
- 1 mark for advantage: Produces significantly smaller file sizes // faster transmission/download speeds // saves storage capacity.
- 1 mark for disadvantage: Discards data permanently // some reduction in sound quality / fidelity // cannot reconstruct original file.
題目 23 · Structured Descriptive & Explanatory
4 分
A handheld barcode scanner is connected to a computer at a parcel depot. When an operator scans a package, a hardware interrupt is sent to the Central Processing Unit (CPU).

Explain how the CPU handles this interrupt.
查看答案詳解

解題

When a hardware interrupt is generated, the CPU completes its current instruction execution cycle before servicing the interrupt.

1. Detection: At the end of the current FDE cycle, the CPU checks if an interrupt flag is set.
2. State Saving: The current state of execution (including the values in the Program Counter and general-purpose registers) is copied and saved to a dedicated memory area (the stack) to allow resumption later.
3. Identification & Prioritisation: The CPU identifies the source of the interrupt (the scanner) and evaluates its priority level.
4. Servicing (ISR): The Program Counter is loaded with the memory address of the specific Interrupt Service Routine (ISR) / interrupt handler, and the ISR code executes to read and process the scanned barcode data.
5. Restoration & Resumption: After the ISR completes, the saved register contents and original Program Counter value are retrieved from the stack, allowing the CPU to resume execution of the interrupted process exactly where it left off.

評分準則

Award 1 mark per valid point up to a maximum of 4 marks:
- The CPU checks for an interrupt at the end of the current (fetch–decode–execute) cycle
- The current contents of the registers / Program Counter / current state are saved (to a stack)
- The source / origin / priority of the interrupt is determined // higher-priority interrupts take precedence
- The address of the relevant Interrupt Service Routine (ISR) / interrupt handler is loaded (into the PC) // the ISR is executed
- The saved register values / previous state are restored (from the stack) once the ISR has finished
- The CPU resumes execution of the interrupted program / task

Guidance:
- Accept 'interrupt handler' in place of 'Interrupt Service Routine / ISR'
- Do not accept vague statements such as 'the CPU stops everything immediately' without stating that the current cycle completes or state is saved.
題目 24 · table-matching
4 分
A company is conducting training on digital security threats. Complete the table by identifying the cyber threat described by each statement.

| Description | Security threat |
| :--- | :--- |
| Malicious software that encrypts a user's files and blocks access to the computer system, demanding payment to restore access. | [ 1 ] |
| Malicious code installed on a user's computer or server that automatically redirects web traffic to a fake website without the user's consent or knowledge. | [ 2 ] |
| An attack that attempts to crack a password or key by systematically generating and testing every possible combination of characters. | [ 3 ] |
| Software that secretly monitors a user's actions and keystrokes on a device to collect sensitive personal data. | [ 4 ] |
查看答案詳解

解題

1. Ransomware is malicious software designed to lock or encrypt files, holding them hostage until a ransom is paid.
2. Pharming modifies DNS settings or host files to redirect a user visiting a legitimate URL to a fraudulent clone site.
3. A brute-force attack attempts all possible character combinations sequentially until the correct password/key is discovered.
4. Spyware covertly records user activities (such as keystrokes via keyloggers) and transmits this information to third parties.

評分準則

1 mark for each correct term identified (maximum 4 marks):
1. Ransomware
2. Pharming
3. Brute-force attack // Brute-force
4. Spyware // Keylogger (BOD)

Reject:
- Phishing for item 2
- Hacking for item 3 (TV - too vague)
- Adware / Virus for item 4

準備好測試自己了嗎?

將這些筆記轉化為考試練習。獲取此課題的無限量AI題目,即時批改及詳細解析。

練習此課題

卷二: Algorithms, Programming and Logic

Answer all questions. Calculators are not permitted.
18 題目 · 68 分
題目 1 · multiple_choice
1 分
A sailing club maintains a single-table database named `Member` with the following fields:

- `MemberID` (INTEGER, Primary Key)
- `FullName` (TEXT)
- `Age` (INTEGER)
- `Active` (BOOLEAN)

Which SQL statement correctly counts the number of active members who are under 18 years old?
  1. A.SELECT COUNT(MemberID) FROM Member WHERE Age < 18 AND Active = TRUE
  2. B.SELECT SUM(MemberID) FROM Member WHERE Age < 18 OR Active = TRUE
  3. C.SELECT COUNT(MemberID) FROM Member WHERE Age <= 18 AND Active = FALSE
  4. D.SELECT SUM(Age) FROM Member WHERE Age < 18 AND Active = TRUE
查看答案詳解

解題

To count the number of records meeting specific criteria, the `COUNT()` aggregate function is used in the `SELECT` clause. The condition requires both criteria to be satisfied simultaneously: the member must be strictly under 18 (`Age < 18`) and currently active (`Active = TRUE`), so the logical operator `AND` is required in the `WHERE` clause.

- Option A correctly uses `COUNT(MemberID)` with the conditions `Age < 18 AND Active = TRUE`.
- Option B incorrectly uses `SUM(MemberID)` and the `OR` operator.
- Option C uses `< = 18` and `Active = FALSE`.
- Option D uses `SUM(Age)`, which adds up the ages rather than counting the members.

評分準則

1 mark for A.

[1 mark total]
題目 2 · multiple_choice
1 分
An online ticket booking algorithm applies a range check to ensure an entered passenger age is between 12 and 120 inclusive.

Which set of test data represents boundary test data for this range check?
  1. A.12, 120
  2. B.11, 12, 120, 121
  3. C.13, 45, 90, 119
  4. D.-5, 0, 121, 150
查看答案詳解

解題

In the Cambridge IGCSE Computer Science syllabus:
- Extreme data refers to the minimum and maximum acceptable values (12 and 120).
- Boundary data consists of the values at the limits of acceptable ranges paired with the immediate invalid values just outside those limits (i.e. the smallest valid value paired with the largest rejected value below it: 11 and 12; and the largest valid value paired with the smallest rejected value above it: 120 and 121).

Therefore, the boundary test data set is 11, 12, 120, and 121.

評分準則

1 mark for B.

[1 mark total]
題目 3 · short_answer
1.5 分
State the purpose of a primary key in a database table and give one characteristic of a primary key field.
查看答案詳解

解題

A primary key is a field that uniquely identifies each individual record (or row) in a database table. A key characteristic of a primary key is that every value in this field must be unique (no duplicate values permitted) and it cannot contain a null value.

評分準則

Award up to 1.5 marks:
• 1 mark for stating the purpose: To uniquely identify each record / row (in a table).
• 0.5 marks for one characteristic: Each value must be unique // cannot contain duplicate values // cannot be null / empty.
題目 4 · short_answer
1.5 分
State what is meant by the terms 'normal test data' and 'extreme test data' when testing an algorithm.
查看答案詳解

解題

Normal test data is valid data that is accepted by the algorithm and tests that the program works under standard, everyday conditions. Extreme test data is valid data at the outermost acceptable limits (the maximum and minimum acceptable values) to verify that boundary values are handled correctly.

評分準則

Award up to 1.5 marks:
• 0.75 marks: Normal data – valid / accepted data (within the expected range) to test normal operation.
• 0.75 marks: Extreme data – valid / accepted data at the largest or smallest (maximum/minimum) allowable boundary/limit.
題目 5 · short_answer
1.5 分
Describe the main difference between a function and a procedure in a computer program.
查看答案詳解

解題

Both functions and procedures are subroutines that contain a named block of code. The fundamental difference is that a function returns a value back to the calling statement (and is called within an expression), whereas a procedure executes a sequence of commands without returning a value (and is called using a CALL statement).

評分準則

Award up to 1.5 marks:
• 1.5 marks for a complete distinction: A function returns a value (to the calling code / expression) (1) whereas a procedure does not return a value (0.5).
• Allow: Function is called as part of an expression / procedure is invoked via CALL.
題目 6 · short_answer
1.5 分
State what is meant by a 'pre-condition loop' and a 'post-condition loop' in algorithm design.
查看答案詳解

解題

A pre-condition loop (such as a WHILE loop) checks the test condition at the start before executing the loop body; if the condition is false initially, the statements inside may execute zero times. A post-condition loop (such as a REPEAT...UNTIL loop) checks the condition at the end after executing the body, ensuring the loop executes at least once.

評分準則

Award up to 1.5 marks:
• 0.75 marks: Pre-condition loop tests the condition at the start / before loop body (may execute zero times).
• 0.75 marks: Post-condition loop tests the condition at the end / after loop body (always executes at least once).
題目 7 · short_answer
1.5 分
Define what is meant by 'data validation' and give one example of a validation check.
查看答案詳解

解題

Data validation is an automatic process performed by software to check that user input meets specific criteria or rules (e.g. sensible, valid data type, within allowed limits) before being accepted. Examples of standard validation checks include range check, length check, type check, presence check, format check, and check digit.

評分準則

Award up to 1.5 marks:
• 1 mark for definition: Automated / computer check to ensure data is sensible / reasonable / meets specified rules or criteria (before processing).
• 0.5 marks for one valid named check: Range (check) // Length (check) // Type (check) // Presence (check) // Format (check) // Check digit.
題目 8 · short_answer
1.5 分
State what is meant by a two-dimensional (2D) array and give the purpose of using indices with an array.
查看答案詳解

解題

A 2D array is a structured collection of items of the same data type arranged in a grid of rows and columns (requiring two index values to identify any single element). Indices (or subscripts) are integer values used to specify the exact position and access or modify a specific item in the array.

評分準則

Award up to 1.5 marks:
• 0.75 marks for 2D array definition: A data structure storing elements of the same data type in a grid / rows and columns / requiring two dimensions to reference an element.
• 0.75 marks for indices purpose: To uniquely identify / access / locate / point to a specific element / position in the array.
題目 9 · open
4.75 分
An algorithm is written to input the mass in kilograms of 30 luggage items at an airport check-in desk, calculate the average mass, and count how many items exceed the 23.0 kg allowance limit.

The algorithm contains four errors:

01 TotalMass <- 0
02 HeavyCount <- 0
03 FOR Counter <- 1 TO 30
04 INPUT ItemMass
05 TotalMass <- TotalMass + Counter
06 IF ItemMass >= 23.0 THEN
07 HeavyCount <- HeavyCount + 1
08 ENDIF
09 NEXT Counter
10 AverageMass <- TotalMass / HeavyCount
11 OUTPUT "Total heavy items: ", HeavyCount
12 OUTPUT "Average mass: ", AverageMass

Identify three numbered lines containing errors and write the corrected pseudocode statement for each line. State how line 06 must be amended if items weighing exactly 23.0 kg are permitted without penalty.
查看答案詳解

解題

Error 1 (Line 05): The loop counter was being accumulated rather than the input luggage mass. Corrected line: TotalMass <- TotalMass + ItemMass

Error 2 (Line 06): The condition incorrectly used '>=' which flags exactly 23.0 kg as overweight instead of exceeding it. Corrected line: IF ItemMass > 23.0 THEN

Error 3 (Line 10): The average calculation divided the total mass by HeavyCount instead of the total number of items (30). Corrected line: AverageMass <- TotalMass / 30

Line 06 amendment explanation: Replacing '>=' with '>' ensures items of exactly 23.0 kg are excluded from the overweight count.

評分準則

1 mark for identifying Line 05 and writing 'TotalMass <- TotalMass + ItemMass'
1 mark for identifying Line 06 and writing 'IF ItemMass > 23.0 THEN'
1 mark for identifying Line 10 and writing 'AverageMass <- TotalMass / 30' // 'AverageMass <- TotalMass / Counter' (if counter stepped appropriately)
1.75 marks for stating the specific correction/explanation for boundary handling on line 06 (changing '>=' to '>' to exclude boundary value 23.0 from penalty).
題目 10 · open
4.75 分
A 1D array `ScoreList` contains 80 integer test results indexed from 1 to 80. The following pseudocode algorithm performs a linear search to find whether a target score stored in `Target` exists in the array:

01 DECLARE Found : BOOLEAN
02 DECLARE Index : INTEGER
03 Found <- FALSE
04 Index <- 1
05 WHILE Found = FALSE AND Index <= 80 DO
06 IF ScoreList[Index] = Target THEN
07 Found <- TRUE
08 ENDIF
09 Index <- Index + 1
10 ENDWHILE

(a) Modify the algorithm so that it terminates immediately when the target is found without unnecessary iterations, and also stores the position where it was found in a variable `FoundIndex` (or -1 if not found).
(b) Write the modified pseudocode for lines 01 to 10.
查看答案詳解

解題

To store the location and prevent index incrementing past the target position upon match:

DECLARE Found : BOOLEAN
DECLARE Index, FoundIndex : INTEGER
Found <- FALSE
FoundIndex <- -1
Index <- 1
WHILE NOT Found AND Index <= 80 DO
IF ScoreList[Index] = Target THEN
Found <- TRUE
FoundIndex <- Index
ELSE
Index <- Index + 1
ENDIF
ENDWHILE

By placing `Index <- Index + 1` inside an `ELSE` clause, `Index` accurately retains the matched position, and `FoundIndex` captures it while the loop condition `Found = FALSE` halts any subsequent execution.

評分準則

1 mark: Correct declaration/initialisation of `FoundIndex <- -1`.
1 mark: Assigning `FoundIndex <- Index` inside the selection structure when match is true.
1.75 marks: Ensuring `Index` is only incremented when target is not matched (e.g. within `ELSE`) or loop stops immediately without off-by-one index increment.
1 mark: Valid overall logic maintaining standard pseudocode conventions.
題目 11 · open
4.75 分
A school sports day recording system stores student finish times in seconds. The following pseudocode routine inputs times for 40 runners into an array `RaceTime[1:40]`, finds the fastest (minimum) time, and outputs the runner number (array index) of the winner.

01 DECLARE RaceTime : ARRAY[1:40] OF REAL
02 DECLARE Index, WinnerIndex : INTEGER
03 DECLARE FastestTime : REAL
04 FastestTime <- 0.0
05 FOR Index <- 1 TO 40
06 INPUT RaceTime[Index]
07 IF RaceTime[Index] < FastestTime THEN
08 FastestTime <- RaceTime[Index]
09 WinnerIndex <- Index
10 ENDIF
11 NEXT Index
12 OUTPUT "Winning runner: ", WinnerIndex, " with time: ", FastestTime

(a) Identify the logic flaw in line 04 that causes the algorithm to fail to find the fastest runner.
(b) Write a corrected version of the initialisation in lines 04 to 06, or state the correct value to assign to `FastestTime` before the loop.
查看答案詳解

解題

(a) A minimum search algorithm must initialise the comparison variable to a value greater than or equal to any valid possible input (e.g., a very large number such as 999.9) or to the first element in the array (`RaceTime[1]`). When set to 0.0, any positive race time will fail `RaceTime[Index] < 0.0`, resulting in `FastestTime` remaining 0.0 and `WinnerIndex` remaining unassigned.

(b) Method 1:
INPUT RaceTime[1]
FastestTime <- RaceTime[1]
WinnerIndex <- 1
FOR Index <- 2 TO 40
INPUT RaceTime[Index]
IF RaceTime[Index] < FastestTime THEN
FastestTime <- RaceTime[Index]
WinnerIndex <- Index
ENDIF
NEXT Index

Method 2:
FastestTime <- 9999.0

評分準則

1.75 marks: Clear explanation that setting initial minimum to 0.0 prevents any valid positive input from being smaller than `FastestTime` // condition `RaceTime[Index] < FastestTime` is never true.
1.5 marks: Giving a valid alternative initialisation (e.g., initialising `FastestTime` to a very high constant like `999.0` or reading first input before the loop).
1.5 marks: Adjusting loop index bounds (2 TO 40) if first element is used, or correctly structuring the updated pseudocode snippet.
題目 12 · open
4.75 分
A program reads text records from an existing file `Sensors.txt`. Each line contains a single integer reading representing device humidity percentage. The program must count how many readings are abnormal (strictly less than 30 or strictly greater than 70) and write all abnormal values to a new file named `Alerts.txt`.

Complete the following pseudocode algorithm by writing the missing statements in spaces (i) to (v).

DECLARE Reading, AbnormalCount : INTEGER
AbnormalCount <- 0
OPENFILE "Sensors.txt" FOR READ
OPENFILE "Alerts.txt" FOR WRITE
WHILE NOT EOF("Sensors.txt") DO
READFILE "Sensors.txt", Reading
IF ......... (i) ......... THEN
......... (ii) .........
......... (iii) .........
ENDIF
ENDWHILE
......... (iv) .........
......... (v) .........
OUTPUT "Total alerts logged: ", AbnormalCount
查看答案詳解

解題

The missing sections are:
(i) Selection condition to test for abnormal limits using logical OR: `Reading < 30 OR Reading > 70`
(ii) Incrementing the counter variable: `AbnormalCount <- AbnormalCount + 1`
(iii) Writing the abnormal value into the open output file: `WRITEFILE "Alerts.txt", Reading`
(iv) Closing the input file: `CLOSEFILE "Sensors.txt"`
(v) Closing the output file: `CLOSEFILE "Alerts.txt"`

評分準則

0.75 mark: (i) `Reading < 30 OR Reading > 70` (reject AND)
1 mark: (ii) `AbnormalCount <- AbnormalCount + 1`
1 mark: (iii) `WRITEFILE "Alerts.txt", Reading`
1 mark: (iv) `CLOSEFILE "Sensors.txt"`
1 mark: (v) `CLOSEFILE "Alerts.txt"` (both close statements must be present to earn all file closing marks).
題目 13 · Trace Tables & Truth Tables
5 分
An algorithm is designed to process an array of six integer values representing package weights in kilograms.

The algorithm is written in pseudocode:

```text
01 DECLARE Weight : ARRAY[1:6] OF INTEGER
02 DECLARE TotalWeight, HeavyCount, Index, Item : INTEGER
03 Weight[1] <- 14
04 Weight[2] <- 7
05 Weight[3] <- 22
06 Weight[4] <- 9
07 Weight[5] <- 18
08 Weight[6] <- 5
09 TotalWeight <- 0
10 HeavyCount <- 0
11 FOR Index <- 1 TO 6
12 Item <- Weight[Index]
13 IF Item > 10 THEN
14 TotalWeight <- TotalWeight + Item
15 HeavyCount <- HeavyCount + 1
16 ELSE
17 TotalWeight <- TotalWeight - Item
18 ENDIF
19 NEXT Index
20 OUTPUT "Heavy packages: ", HeavyCount
21 OUTPUT "Final balance: ", TotalWeight
```

Complete the trace table for the algorithm.

| Index | Item | HeavyCount | TotalWeight | OUTPUT |
|---|---|---|---|---|
| | | 0 | 0 | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
查看答案詳解

解題

Step-by-step trace of the loop:

1. Initialisation (lines 09–10):
- `TotalWeight` = 0
- `HeavyCount` = 0

2. Iteration 1 (`Index` = 1):
- `Item` = `Weight[1]` = 14
- `Item > 10` is TRUE (14 > 10)
- `TotalWeight` = 0 + 14 = 14
- `HeavyCount` = 0 + 1 = 1

3. Iteration 2 (`Index` = 2):
- `Item` = `Weight[2]` = 7
- `Item > 10` is FALSE (7 <= 10)
- `TotalWeight` = 14 - 7 = 7
- `HeavyCount` remains 1 (no entry needed)

4. Iteration 3 (`Index` = 3):
- `Item` = `Weight[3]` = 22
- `Item > 10` is TRUE (22 > 10)
- `TotalWeight` = 7 + 22 = 29
- `HeavyCount` = 1 + 1 = 2

5. Iteration 4 (`Index` = 4):
- `Item` = `Weight[4]` = 9
- `Item > 10` is FALSE (9 <= 10)
- `TotalWeight` = 29 - 9 = 20
- `HeavyCount` remains 2

6. Iteration 5 (`Index` = 5):
- `Item` = `Weight[5]` = 18
- `Item > 10` is TRUE (18 > 10)
- `TotalWeight` = 20 + 18 = 38
- `HeavyCount` = 2 + 1 = 3

7. Iteration 6 (`Index` = 6):
- `Item` = `Weight[6]` = 5
- `Item > 10` is FALSE (5 <= 10)
- `TotalWeight` = 38 - 5 = 33
- `HeavyCount` remains 3

8. Outputs (lines 20–21):
- `Heavy packages: 3`
- `Final balance: 33`

評分準則

1 mark for each of the following points (max 5):
- Correct `Index` column (1, 2, 3, 4, 5, 6) and `Item` column (14, 7, 22, 9, 18, 5)
- Correct updates to `HeavyCount` (1, 2, 3 entered at iterations 1, 3, and 5)
- Correct updates to `TotalWeight` for iterations 1 to 3 (14, 7, 29)
- Correct updates to `TotalWeight` for iterations 4 to 6 (20, 38, 33)
- Correct final outputs: `Heavy packages: 3` and `Final balance: 33` (accept outputs without string labels if numerical values 3 and 33 are present)
題目 14 · subjective
5 分
An algorithm processes a list of sensor values stored in a 1D array named Readings. The algorithm is written in pseudocode as follows: Total <- 0 Count <- 0 FOR Index <- 1 TO 6 CurrentVal <- Readings[Index] IF CurrentVal > 10 THEN Total <- Total + CurrentVal Count <- Count + 1 ENDIF NEXT Index OUTPUT "Filtered Total:", Total OUTPUT "Count:", Count Complete the trace table for the algorithm using the following array data: Readings[1] = 14, Readings[2] = 8, Readings[3] = 22, Readings[4] = 15, Readings[5] = 9, Readings[6] = 18.
查看答案詳解

解題

Step 1: Initialise Total <- 0 and Count <- 0 in the first row. Step 2: Index = 1 -> CurrentVal = 14. Since 14 > 10, Total becomes 0 + 14 = 14, Count becomes 0 + 1 = 1. Step 3: Index = 2 -> CurrentVal = 8. Since 8 > 10 is false, Total and Count remain unchanged. Step 4: Index = 3 -> CurrentVal = 22. Since 22 > 10, Total becomes 14 + 22 = 36, Count becomes 1 + 1 = 2. Step 5: Index = 4 -> CurrentVal = 15. Since 15 > 10, Total becomes 36 + 15 = 51, Count becomes 2 + 1 = 3. Step 6: Index = 5 -> CurrentVal = 9. Since 9 > 10 is false, Total and Count remain unchanged. Step 7: Index = 6 -> CurrentVal = 18. Since 18 > 10, Total becomes 51 + 18 = 69, Count becomes 3 + 1 = 4. Step 8: Final outputs are printed: 'Filtered Total: 69' and 'Count: 4'.

評分準則

1 mark for initialising Total (0) and Count (0). 1 mark for correct Index values (1 to 6) and matching CurrentVal entries (14, 8, 22, 15, 9, 18). 1 mark for all correct updates to Total (14, 36, 51, 69) with no values entered on false conditions. 1 mark for all correct updates to Count (1, 2, 3, 4) with no values entered on false conditions. 1 mark for correct final output values ('Filtered Total: 69' and 'Count: 4' // '69' and '4').
題目 15 · Logic Circuit Drawing
5 分
An automated ventilation system in an agricultural greenhouse operates an exhaust fan based on conditions monitored by three digital inputs:

- \(T = 1\) if temperature is above 30°C (0 otherwise)
- \(H = 1\) if humidity is above 75% (0 otherwise)
- \(W = 1\) if the roof window is open (0 otherwise)

The exhaust fan turns on (\(X = 1\)) if:
- the temperature is not above 30°C AND the humidity is above 75%
OR
- the temperature is above 30°C AND the roof window is not open.

Draw the logic circuit to represent this system. Each logic gate must have a maximum of two inputs.
查看答案詳解

解題

The system requirements translate into the Boolean logic expression:
\(X = (\text{NOT } T \text{ AND } H) \text{ OR } (T \text{ AND } \text{NOT } W)\)

Circuit construction:
1. Place a NOT gate connected to input line \(T\).
2. Place a 2-input AND gate with inputs connected to the output of the first NOT gate (\(\text{NOT } T\)) and input line \(H\).
3. Place a NOT gate connected to input line \(W\).
4. Place a 2-input AND gate with inputs connected to input line \(T\) and the output of the second NOT gate (\(\text{NOT } W\)).
5. Place a 2-input OR gate with inputs connected to the outputs of the two AND gates, with its output connected to \(X\).

評分準則

1 mark for each of the following (max 5 marks):
- 1 mark for correct NOT gate on input T.
- 1 mark for correct 2-input AND gate with inputs from (NOT T) and H.
- 1 mark for correct NOT gate on input W.
- 1 mark for correct 2-input AND gate with inputs from T and (NOT W).
- 1 mark for correct 2-input OR gate taking the outputs of both AND gates and connecting to X.

Notes:
- Accept standard logic gate symbols only.
- Deduct 1 mark if gates have more than two inputs.
題目 16 · short-answer
4 分
A community music academy keeps records of musical instruments available for student hire in a single-table database named `INSTRUMENT`.

A sample of the data is shown below:

| InstrumentID | InstrumentType | YearManufactured | MonthlyHireFee | Insured |
| :--- | :--- | :--- | :--- | :--- |
| INS042 | Flute | 2021 | 18.50 | TRUE |
| INS109 | Cello | 2019 | 34.00 | TRUE |
| INS204 | Trumpet | 2022 | 22.00 | FALSE |

(a) State the purpose of a primary key in a database table. [1]
(b) Identify the field that is most suitable as the primary key for the `INSTRUMENT` table, and give a reason for your choice. [2]
(c) State the most appropriate data type for the `MonthlyHireFee` field. [1]
查看答案詳解

解題

(a) A primary key is a field (or attribute) that uniquely identifies each record (or row) in a database table.
(b) Field: `InstrumentID`
Reason: Every instrument has a distinct identifier code, ensuring that no two records contain duplicate values in this field (unlike `InstrumentType` or `YearManufactured` which can repeat).
(c) Data type: Real (or Currency / Decimal) because it stores numerical data with fractional / decimal values.

評分準則

(a) 1 mark for:
- (A field that) uniquely identifies each record / row in a table // prevents duplicate records.

(b) 2 marks:
- 1 mark for identifying `InstrumentID`.
- 1 mark for valid justification (e.g. each instrument has a unique value / it contains unique data for every entry / other fields like `InstrumentType` can have duplicate values).

(c) 1 mark for:
- Real // Currency (accept Decimal / Float; reject Integer / String / Text).
題目 17 · short-answer
4 分
An outdoor adventure centre stores details of group activity bookings in a database table named `BOOKING`.

The structure of the table is shown below:
- `BookingID` (Text)
- `ActivityName` (Text)
- `Participants` (Integer)
- `EquipmentProvided` (Boolean)
- `Cost` (Real)

Write an SQL script to display the `BookingID`, `ActivityName`, and `Cost` for all records where `Participants` is greater than 8 and `EquipmentProvided` is `TRUE`.

The output must be sorted from the highest cost to the lowest cost.
查看答案詳解

解題

The query requires four clauses:
1. `SELECT BookingID, ActivityName, Cost` to choose only the required fields.
2. `FROM BOOKING` to specify the table name.
3. `WHERE Participants > 8 AND EquipmentProvided = TRUE` to filter for bookings with more than 8 participants where equipment is provided.
4. `ORDER BY Cost DESCENDING` (or `DESC`) to sort the records in descending order of cost.

評分準則

Award 1 mark for each correct clause (maximum 4 marks):
- 1 mark: `SELECT BookingID, ActivityName, Cost` (must have all three fields and no others)
- 1 mark: `FROM BOOKING`
- 1 mark: `WHERE Participants > 8 AND EquipmentProvided = TRUE` (accept `EquipmentProvided = True` // `EquipmentProvided`)
- 1 mark: `ORDER BY Cost DESCENDING` (accept `ORDER BY Cost DESC`)

Note: Keywords do not need to be uppercase. Semicolon at the end is optional.
題目 18 · Extended Algorithm Design
15 分
A regional kayak club records the performance of 30 kayakers in an annual river time trial.

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

- Inputs and validates the details of 30 kayakers:
- Kayaker ID (an integer from 100 to 999 inclusive)
- Kayaker name (presence check; must not be empty)
- Division (a single character: 'A' for Advanced, 'I' for Intermediate, or 'N' for Novice)
- Time in minutes (a real number greater than 0 and at most 180.0)
Data must be stored in suitable one-dimensional (1D) arrays.

- Calculates and outputs:
- The average completion time of all 30 kayakers.
- The fastest (lowest) completion time, along with the ID and name of the kayaker(s) who achieved it.
- The total number of kayakers in each division ('A', 'I', 'N').

- Allows a user to search for a specific kayaker by entering a Kayaker ID:
- If the ID is found, outputs the kayaker's name, division, and completion time.
- If the ID is not found, outputs an appropriate message.

You must use meaningful variable names and include comments where appropriate.
You do not need to declare all variables, but any arrays used must be declared.
查看答案詳解

解題

// Array Declarations
DECLARE KayakerID : ARRAY[1:30] OF INTEGER
DECLARE KayakerName : ARRAY[1:30] OF STRING
DECLARE KayakerDivision : ARRAY[1:30] OF CHAR
DECLARE KayakerTime : ARRAY[1:30] OF REAL

// Variable Declarations
DECLARE TotalTime, AverageTime, FastestTime : REAL
DECLARE CountA, CountI, CountN : INTEGER
DECLARE SearchID, i : INTEGER
DECLARE Found : BOOLEAN

// Initialise totalling and counting variables
TotalTime <- 0.0
CountA <- 0
CountI <- 0
CountN <- 0

// Input and validation for 30 kayakers
FOR i <- 1 TO 30
// Input and range check for Kayaker ID
REPEAT
OUTPUT "Enter Kayaker ID (100 to 999): "
INPUT KayakerID[i]
UNTIL KayakerID[i] >= 100 AND KayakerID[i] <= 999

// Input and presence check for Kayaker Name
REPEAT
OUTPUT "Enter Kayaker Name: "
INPUT KayakerName[i]
UNTIL KayakerName[i] <> ""

// Input and check for valid Division
REPEAT
OUTPUT "Enter Division ('A', 'I', 'N'): "
INPUT KayakerDivision[i]
UNTIL KayakerDivision[i] = 'A' OR KayakerDivision[i] = 'I' OR KayakerDivision[i] = 'N'

// Input and range check for Completion Time
REPEAT
OUTPUT "Enter Completion Time in minutes (0 to 180): "
INPUT KayakerTime[i]
UNTIL KayakerTime[i] > 0.0 AND KayakerTime[i] <= 180.0

// Accumulate total time
TotalTime <- TotalTime + KayakerTime[i]

// Count division occurrences
IF KayakerDivision[i] = 'A' THEN
CountA <- CountA + 1
ELSE
IF KayakerDivision[i] = 'I' THEN
CountI <- CountI + 1
ELSE
CountN <- CountN + 1
ENDIF
ENDIF
NEXT i

// Calculate and output average time
AverageTime <- TotalTime / 30
OUTPUT "Average completion time: ", AverageTime, " minutes"

// Output counts for each division
OUTPUT "Advanced count: ", CountA
OUTPUT "Intermediate count: ", CountI
OUTPUT "Novice count: ", CountN

// Find the fastest (minimum) time
FastestTime <- KayakerTime[1]
FOR i <- 2 TO 30
IF KayakerTime[i] < FastestTime THEN
FastestTime <- KayakerTime[i]
ENDIF
NEXT i

// Output all kayakers who achieved the fastest time
OUTPUT "Fastest time: ", FastestTime, " minutes"
FOR i <- 1 TO 30
IF KayakerTime[i] = FastestTime THEN
OUTPUT "Fastest Kayaker - ID: ", KayakerID[i], ", Name: ", KayakerName[i]
ENDIF
NEXT i

// Linear search for a kayaker by ID
OUTPUT "Enter Kayaker ID to search: "
INPUT SearchID
Found <- FALSE

FOR i <- 1 TO 30
IF KayakerID[i] = SearchID THEN
OUTPUT "Record Found:"
OUTPUT "Name: ", KayakerName[i]
OUTPUT "Division: ", KayakerDivision[i]
OUTPUT "Time: ", KayakerTime[i], " minutes"
Found <- TRUE
ENDIF
NEXT i

IF Found = FALSE THEN
OUTPUT "Kayaker not found."
ENDIF

評分準則

Award marks based on the following two criteria:

AO2: Application of programming concepts & techniques (Max 9 marks)
- 1 mark: Four 1D arrays correctly declared with appropriate data types and size 30.
- 1 mark: Loop running 30 iterations for data entry.
- 1 mark: Validation loop / check for Kayaker ID (range 100 to 999).
- 1 mark: Validation loop / check for Kayaker Name (non-empty) AND Division ('A', 'I', 'N').
- 1 mark: Validation loop / check for Time (> 0 and <= 180.0).
- 1 mark: Correct calculation of total and average completion time.
- 1 mark: Correct counting logic for all three divisions ('A', 'I', 'N').
- 1 mark: Correct algorithm to find minimum completion time (fastest) and display corresponding name/ID.
- 1 mark: Correct linear search algorithm comparing SearchID to stored IDs, outputting details if found and a 'not found' message otherwise.

AO3: Solution design, logic structure, and quality (Max 6 marks)
- Band 3 (5–6 marks): The algorithm provides a fully working, robust solution meeting all requirements. Logic is efficient, well-structured, syntax/conventions are consistent throughout, and meaningful identifiers and appropriate comments are present.
- Band 2 (3–4 marks): The algorithm covers most requirements with minor omissions or slight logic flaws. Reasonably structured with generally consistent identifiers.
- Band 1 (1–2 marks): The algorithm makes an attempt at several parts of the problem but contains substantial logic errors or omissions. Limited structure and clarity.
- 0 marks: No creditable response.

想知道自己有幾分把握?

thinka 是 DSE 學生用的 AI 練習應用程式,有無限量練習題、即時自動批改和詳細解題步驟。逾 100,000 名學生用它確認自己真的識,而不只是「以為識」。

想練更多類似題型?在 thinka 無限量操練,即時知道答案。

免費開始練習