Cambridge IGCSE · thinka 原创模拟试题

2025 Cambridge IGCSE Computer Science (0478) 模拟试题及答案详解

Thinka Nov 2025 (V2) Cambridge IGCSE-Style Mock — Computer Science (0478)

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

卷一 Computer Systems

Answer all questions in the space provided. Calculators must not be used.
20 题目 · 74
题目 1 · Short Answer
2
A digital display in a factory uses hexadecimal to show status error codes. One error code is represented as the hexadecimal value 3D. Convert the hexadecimal value 3D into an 8-bit binary number.
查看答案详解

解题

1. Convert the first hex digit '3' to a 4-bit binary nibble: 0011. 2. Convert the second hex digit 'D' (which represents 13 in denary) to a 4-bit binary nibble: 1101. 3. Combine the two nibbles to form the 8-bit binary number: 00111101.

评分标准

1 mark for converting '3' to 0011 or 'D' to 1101. 1 mark for the correct full 8-bit binary number: 00111101.
题目 2 · Short Answer
2
The Program Counter (PC) is a vital register within the CPU. Identify two functions of the Program Counter during the fetch-decode-execute (FDE) cycle.
查看答案详解

解题

During the fetch stage, the Program Counter (PC) holds the memory address of the next instruction that needs to be fetched from RAM. Once that address is sent to the Memory Address Register (MAR), the PC is incremented by 1 so that it points to the memory location of the next instruction in sequence.

评分标准

1 mark for stating that it holds the address of the next instruction to be fetched. 1 mark for stating that it increments/updates to point to the next instruction.
题目 3 · Short Answer
2
Data is transmitted over a long distance using serial simplex transmission. Describe what is meant by serial simplex transmission.
查看答案详解

解题

Serial transmission means that data is sent bit by bit, sequentially, along a single communication channel or wire. Simplex transmission means that the communication is unidirectional, allowing data to travel in only one direction from sender to receiver.

评分标准

1 mark for describing serial (data sent one bit at a time / sequentially / along a single wire). 1 mark for describing simplex (data transmission in one direction only).
题目 4 · Short Answer
2
Explain how a checksum is used to detect errors in transmitted data.
查看答案详解

解题

Before transmission, the sender runs an algorithm on the block of data to calculate a numerical value called a checksum. This checksum is appended to the data block and transmitted. Upon receipt, the receiver runs the same algorithm on the received data to calculate its own checksum. If the receiver's calculated checksum does not match the transmitted checksum, an error has occurred during transmission, and a request for retransmission is usually sent.

评分标准

1 mark for explaining that the sender calculates a checksum value from the data and transmits it with the data. 1 mark for explaining that the receiver recalculates the checksum and compares it to detect a mismatch/error.
题目 5 · Short Answer
2
Describe two functions of an Operating System (OS) in a modern computer system.
查看答案详解

解题

Operating systems perform several vital infrastructure tasks, including: 1. Memory management: Allocating and deallocating RAM for active programs and preventing them from overwriting each other's memory. 2. File management: Controlling how data is stored, organised, named, and retrieved on secondary storage devices. 3. Hardware/Device management: Utilizing device drivers to manage input, output, and storage peripheral devices.

评分标准

1 mark for describing one valid function (e.g., memory management, file/storage management, processor scheduling/multitasking, security/user access management, hardware/peripheral management). 1 mark for describing a second distinct, valid function.
题目 6 · Short Answer
2
A user enters a website URL into their browser. Describe the role of a Domain Name Server (DNS) in retrieving the webpage.
查看答案详解

解题

When a URL is entered, the browser queries a Domain Name Server (DNS). The DNS contains a database that maps domain names (like website URLs) to their corresponding IP addresses. The DNS looks up the domain name, retrieves the matching numeric IP address, and returns it to the web browser so that the browser can establish a connection with the web server hosting the site.

评分标准

1 mark for explaining that the DNS looks up/translates the domain name (URL) to find its matching IP address. 1 mark for returning the IP address to the browser so it can locate and request the webpage from the correct web server.
题目 7 · Short Answer
2
A company installs a packet-filtering firewall to protect its network. State two ways a firewall can protect a network from unauthorised access.
查看答案详解

解题

A firewall acts as a barrier between a trusted internal network and untrusted external networks. It protects the network by: 1. Inspecting all incoming and outgoing data packets. 2. Filtering and blocking packets that do not satisfy pre-configured security rules (such as blocking unauthorised IP addresses, domain names, or specific port numbers).

评分标准

1 mark for stating that it inspects/monitors incoming and outgoing traffic. 1 mark for stating that it blocks traffic based on pre-defined security rules (or by blocking unauthorised ports/IP addresses).
题目 8 · Short Answer
2
Explain how a resistive touch screen detects a user's touch.
查看答案详解

解题

A resistive touch screen consists of multiple layers, primarily two thin, conductive, and resistive layers separated by a small gap. When a finger or stylus presses down on the outer layer, the flexible outer layer bends and physically makes contact with the inner layer. This contact completes an electrical circuit and alters the electrical current/resistance at that specific location. A microprocessor measures this change to calculate the precise coordinates of the touch.

评分标准

1 mark for explaining that a press causes two conductive/resistive layers to physically make contact/touch. 1 mark for explaining that this contact completes an electrical circuit (or changes electrical current/resistance), which allows a microprocessor to calculate the coordinates of the touch.
题目 9 · short_answer
2
A network controller stores a subnet identifier as an 8-bit binary register. Currently, the register contains the value:

11011000

A logical right shift of two places is performed on this register. Give the denary value represented by the binary register after this shift has occurred. Show your working.
查看答案详解

解题

1. Perform a logical right shift of two places on the binary string 11011000:
- Shifting right by 2 places gives: 00110110

2. Convert the shifted binary value to denary:
- \(00110110 = 32 + 16 + 4 + 2 = 54\).

评分标准

One mark for correct shifted binary representation:
- 00110110 (1 mark)

One mark for correct denary conversion:
- 54 (1 mark)
题目 10 · short_answer
2
The Central Processing Unit (CPU) contains several dedicated registers used during the fetch-decode-execute (FDE) cycle.

Describe the role of the Program Counter (PC) during the fetch stage of the FDE cycle.
查看答案详解

解题

During the fetch stage, the CPU needs to locate the next instruction. The Program Counter (PC) stores the memory address of this next instruction. This address is sent to the Memory Address Register (MAR) over the address bus. Once the address is copied, the PC is incremented by 1 so that it is ready to point to the subsequent instruction in the sequence.

评分标准

Any two from:
- Holds / stores the memory address of the next instruction to be fetched (1 mark)
- The address is copied / sent to the Memory Address Register (MAR) (1 mark)
- The PC is incremented (by 1) to point to the next instruction (1 mark)
题目 11 · short_answer
2
A user transfers a large high-definition video file from their computer to an external hard drive using a serial data transmission method.

Identify and explain one reason why serial transmission is preferred over parallel transmission for this type of transfer.
查看答案详解

解题

Serial data transmission is highly preferred because it uses a single channel/wire to transmit bits sequentially. This eliminates the risk of data skewing, where bits sent simultaneously across multiple parallel wires arrive at different times due to tiny differences in wire properties. This makes serial transmission much more reliable at high speeds and over longer distances.

评分标准

One mark for identifying a valid benefit:
- No risk of data skewing // Less crosstalk / interference // Less expensive to manufacture/implement (1 mark)

One mark for explanation:
- Data is sent down a single wire/line meaning bits cannot arrive out of synchronization (1 mark)
- Or: Fewer wires/cables are needed which reduces overall cost and simplifies connection design (1 mark)
题目 12 · short_answer
2
Explain how a Domain Name Server (DNS) is used to locate a website when a user types a URL into their web browser.
查看答案详解

解题

When a user inputs a URL, the web browser queries a Domain Name Server (DNS). The DNS searches its database to match the human-readable domain name (e.g., website.com) to its numeric IP address. It then returns this IP address to the web browser so the browser can locate and load the webpage from the appropriate web server.

评分标准

One mark for lookup process:
- The DNS searches its database to find the matching IP address for the given domain name / URL (1 mark)

One mark for response process:
- It returns the IP address back to the browser / client to establish the connection (1 mark)
题目 13 · Structured
6
A network switch displays status codes to network engineers. These codes are represented as binary, hexadecimal, or denary values.

(a) Convert the 12-bit binary number 110100101111 into its hexadecimal equivalent. [2]

(b) An IPv4 address is often represented as four denary numbers. A computer system stores an IP address octet in hexadecimal as 3A. Convert this hexadecimal value into a denary number. [2]

(c) Identify two advantages of using hexadecimal representation instead of binary when displaying these status codes. [2]
查看答案详解

解题

(a) Binary to Hexadecimal:
Group into nibbles: 1101 | 0010 | 1111
Convert each nibble:
- 1101 = 13 in denary = D in hexadecimal
- 0010 = 2 in denary = 2 in hexadecimal
- 1111 = 15 in denary = F in hexadecimal
Result: D2F

(b) Hexadecimal to Denary:
- 3A = (3 * 16) + (10 * 1)
- 3A = 48 + 10 = 58
Result: 58

(c) Two advantages:
1. Hexadecimal is easier/quicker for humans to read/write/comprehend than long strings of binary.
2. Fewer errors are made when typing hexadecimal values compared to binary.

评分标准

(a) 1 mark for grouping into correct nibbles or partial conversion; 1 mark for correct final hexadecimal answer (D2F).
(b) 1 mark for showing correct working (e.g., (3 * 16) + 10); 1 mark for correct denary value (58).
(c) 1 mark per valid advantage, up to 2 marks:
- Easier for humans to read/write/understand (1)
- Shorter to represent on screen (1)
- Less prone to typing/reading errors (1)
- Reject: 'takes up less computer storage space' / 'faster for the computer to process'.
题目 14 · Structured
6
A continuous flow meter in a municipal water treatment plant transmits rate-of-flow measurements to a remote main control unit.

(a) Describe how serial full-duplex data transmission is used to send measurements and receive control signals simultaneously. [3]

(b) The plant is considering upgrading the connection to parallel simplex transmission. Explain one disadvantage of parallel data transmission and one disadvantage of simplex data transmission for this system. [3]
查看答案详解

解题

(a) Serial full-duplex transmission:
- 'Serial' means data bits are sent one by one/single bit at a time over a single wire.
- 'Full-duplex' means data can be sent in both directions simultaneously.
- In this system, measurement data goes to the controller while control signals come from the controller at the same time, using separate transmission lines/frequencies.

(b) Disadvantages of parallel and simplex:
- Parallel disadvantage: High installation cost because it requires multiple physical wires; data skewing can occur over longer distances where bits arrive out of sync.
- Simplex disadvantage: Communication is strictly one-way, meaning the flow meter cannot receive any acknowledgement, calibration commands, or control signals from the main controller.

评分标准

(a) Max 3 marks:
- 1 mark for explaining serial (bits sent one at a time/sequentially down a single wire).
- 1 mark for explaining full-duplex (transmission occurs in both directions at the same time).
- 1 mark for applying it to context (measurements are sent to controller while commands are sent back to the meter simultaneously).
(b) Max 3 marks:
- 1 mark for explaining parallel disadvantage (e.g., higher cost of cabling, prone to skewing over distance).
- 1 mark for explaining simplex disadvantage (e.g., data can only travel in one direction, no feedback/acknowledgement possible).
- 1 mark for applying either point directly to the context of the flow meter system.
题目 15 · Structured
7
A CPU based on the Von Neumann architecture executes instructions sequentially using registers and buses.

(a) Define the specific function of the following components during execution:
(i) Memory Data Register (MDR) [1]
(ii) Accumulator (ACC) [1]
(iii) Control Unit (CU) [1]

(b) Describe the sequence of events that occurs within the CPU during the **fetch** stage of the Fetch-Decode-Execute cycle. [4]
查看答案详解

解题

(a) Register/Component functions:
(i) MDR: Temporary register that stores data or instructions currently being read from or written to main memory (RAM).
(ii) ACC: Temporary register that stores the output of mathematical and logical operations performed by the ALU.
(iii) CU: Coordinates and manages the activities of the CPU, directing the flow of data and decoding instructions.

(b) Steps of the Fetch stage:
1. The program counter (PC) holds the address of the next instruction to be fetched.
2. This address is copied from the PC to the memory address register (MAR) via the address bus.
3. The instruction stored at that address in memory is retrieved and loaded into the memory data register (MDR) via the data bus.
4. Simultaneously, the program counter (PC) is incremented by 1 to point to the next instruction.
5. The instruction in the MDR is copied to the current instruction register (CIR) to be decoded.

评分标准

(a) 1 mark per correct function description:
(i) MDR: Holds data read from memory / about to be written to memory (1).
(ii) ACC: Holds the results of ALU operations (1).
(iii) CU: Decodes instructions / sends control signals / manages execution steps (1).
(b) Max 4 marks for sequential fetch steps:
- Address of next instruction is copied from PC to MAR (1).
- PC is incremented (by 1) (1).
- Instruction at the address in MAR is read from RAM and sent to MDR (1).
- Control signals sent along control bus / data sent along data bus (1).
- Instruction is copied from MDR to CIR (1).
题目 16 · Structured
6
To guarantee that a firmware update file is transmitted from a server to a microcontroller without corruption, a checksum is used.

(a) Describe how a checksum is calculated and used to detect errors during this transmission. [4]

(b) Give two alternative methods of error detection that could be used instead of a checksum. [2]
查看答案详解

解题

(a) How a checksum works:
1. Before transmission, the sending device calculates a checksum value based on the bytes of data in the file using a specific mathematical algorithm.
2. This calculated checksum value is appended to the data packet and transmitted along with the file.
3. The receiving device receives the data and performs the same mathematical algorithm on the received data bytes to calculate its own checksum.
4. The receiver compares its calculated checksum with the transmitted checksum received from the sender.
5. If the two values match, the transmission is assumed to be error-free; if they do not match, an error is detected, and a retransmission is requested.

(b) Two alternative error detection methods:
1. Parity check (parity bit / parity block / parity byte)
2. Automatic Repeat Query (ARQ)
3. Cyclic Redundancy Check (CRC)

评分标准

(a) Max 4 marks:
- Checksum is calculated on the sender's side using an algorithm on the data bytes (1).
- Checksum value is sent along with the data (1).
- Receiver calculates a new checksum from the received data using the same algorithm (1).
- Received and calculated checksum values are compared (1).
- If they match, data is correct; if they mismatch, data is corrupted/retransmission requested (1).
(b) 1 mark per valid alternative method (max 2):
- Parity check (accept parity bit, parity byte, parity block) (1)
- Checksum (not allowed as it is in the question stem)
- Automatic Repeat Query / ARQ (1)
- Echo check (1)
- Cyclic Redundancy Check / CRC (1)
题目 17 · Structured
6
An automated package sorting system in a logistics warehouse identifies boxes on a conveyor belt and sorts them into different bins.

(a) State the name of an input device used to read sorting labels on the boxes and an output device that physically directs the boxes to the correct bins. [2]

(b) Describe how the sensor/input device, microprocessor, and output device work together to automatically sort the boxes. [4]
查看答案详解

解题

(a) Input/Output devices:
- Input device: Barcode scanner / RFID reader / camera (for optical character recognition)
- Output device: Actuator / pneumatic pusher / robotic arm / motor

(b) How they work together:
1. The input device (e.g., barcode scanner) continuously scans the conveyor belt. When a box passes, it reads the barcode/label.
2. The scanned barcode is converted into digital data and sent to the microprocessor.
3. The microprocessor compares the barcode data against a database of shipping records to determine which destination bin the box belongs to.
4. The microprocessor calculates when the box will reach the sorting gate/arm and sends a signal to the actuator (output device) at the correct moment.
5. The actuator activates (e.g., pushes the box) to divert it into the correct bin.

评分标准

(a) 2 marks:
- 1 mark for valid input device (e.g., barcode scanner, RFID reader, camera/OCR scanner) (1).
- 1 mark for valid output device/actuator (e.g., actuator, pneumatic pusher, conveyor motor, robotic arm) (1).
(b) Max 4 marks for explanation:
- Input device captures the label/ID code and sends signal/data to microprocessor (1).
- Microprocessor receives data and processes/compares it against database/lookup table (1).
- Microprocessor determines corresponding output action/destination (1).
- Microprocessor sends a control signal to the actuator/output device (1).
- Actuator performs physical task to route the box (1).
题目 18 · Structured
7
A student uses a computer connected to the internet to log into an online banking portal.

(a) Explain the purpose of a web browser during this process. [3]

(b) Describe how Secure Sockets Layer (SSL) / Transport Layer Security (TLS) protocols are used to establish a secure connection between the student's browser and the bank's web server. [4]
查看答案详解

解题

(a) Purpose of a web browser:
- It acts as client software that allows the user to request web pages from the bank's web server by translating the web server's address (URL).
- It receives HTML/CSS/JavaScript from the server and renders/displays it as a human-readable web page.
- It handles security certificates and protocols (like HTTPS) to ensure encryption and securely transmit user credentials.

(b) SSL/TLS handshake and connection:
1. The browser requests a secure connection (HTTPS) from the bank's web server.
2. The server sends its digital SSL/TLS certificate containing its public key to the browser.
3. The browser checks the certificate against a list of trusted Certification Authorities (CA) to verify the server's identity.
4. Once verified, the browser and server negotiate/exchange symmetric keys (session keys) using asymmetric encryption.
5. All subsequent data sent between the browser and the server is encrypted using these symmetric session keys.

评分标准

(a) Max 3 marks:
- Requests web pages/content from web server using URLs/IP addresses (1).
- Receives and translates/renders HTML/CSS/code into a visual webpage for the user (1).
- Stores cookies / manages history / processes security protocols (1).
(b) Max 4 marks:
- Browser requests a secure session / sends connection request (1).
- Server responds by sending its SSL/TLS certificate (containing its public key) (1).
- Browser validates certificate with CA to ensure authenticity (1).
- If valid, browser and server agree on symmetric encryption keys (session keys) (1).
- Once established, data is encrypted/decrypted during transmission using the session keys (1).
题目 19 · Structured
6
An operating system manages the execution of programs and handles hardware events.

(a) Explain the difference between system software and application software, including one example of each. [3]

(b) Explain how the CPU processes interrupts during program execution. [3]
查看答案详解

解题

(a) Differences between software types:
- System software is designed to run and manage the computer's hardware and software resources (e.g., Operating System, Device Drivers, Compiler).
- Application software is designed to help the user perform specific tasks or solve real-world problems (e.g., Word Processor, Web Browser, Spreadsheet).

(b) How CPU processes interrupts:
1. At the end of each fetch-decode-execute cycle, the CPU checks if an interrupt signal has been received.
2. If an interrupt is detected and its priority is high enough, the CPU halts/suspends the execution of the current program.
3. The CPU saves the current state of the registers (on a stack) so that it can return to it later.
4. The CPU identifies the source of the interrupt and calls the appropriate Interrupt Service Routine (ISR) to handle the event.
5. Once handled, the CPU retrieves the saved register values from the stack and resumes the execution of the original program.

评分标准

(a) Max 3 marks:
- 1 mark for definition of system software (manages hardware/resources) AND a correct example (e.g., OS, utilities, drivers).
- 1 mark for definition of application software (allows user to perform tasks) AND a correct example (e.g., word processor, database client).
- 1 mark for clear contrast (system software is background/essential, application software is user-oriented/optional).
(b) Max 3 marks:
- CPU checks for interrupts at the end of each instruction cycle (1).
- If priority is high, current task is suspended / registers saved to stack (1).
- CPU runs/executes the Interrupt Service Routine (ISR) / interrupt handler (1).
- Registers are restored from the stack and previous task resumes (1).
题目 20 · Structured
6
Robots are increasingly used in automated logistics centers to transport pallets of goods.

(a) State three characteristics that define an automated system as a robot. [3]

(b) Explain the role of feedback in this robotic transport system to prevent collisions with workers and other obstacles. [3]
查看答案详解

解题

(a) Three characteristics of a robot:
1. It must have a physical structure/mechanical body.
2. It must have sensors to detect and collect data from its physical surroundings.
3. It must have actuators to carry out physical movements and actions.
4. It must be programmable/microprocessor-controlled to make independent decisions.

(b) Role of feedback:
1. The robot uses sensors (e.g., LiDAR or ultrasonic sensors) to continuously scan the path ahead for obstacles/people.
2. This sensor data (input) is sent to the microprocessor, which continuously calculates the distance to any detected obstacle.
3. The microprocessor compares this distance against a safety threshold. If an obstacle is detected too close, it sends a control signal to the motors (actuators) to slow down or stop.
4. This continuous loop of sensing, processing, and acting based on the updated environment represents a feedback control loop.

评分标准

(a) Max 3 marks:
- Has a physical/mechanical structure (1).
- Has sensors to read environmental data (1).
- Has actuators to perform physical movement (1).
- Is programmable / controlled by a microprocessor to make decisions (1).
(b) Max 3 marks:
- Sensors continuously detect distance to surrounding objects/workers (1).
- This sensor data is fed back to the microprocessor/controller (1).
- Microprocessor compares data to safety limits and adjusts motor output (1).
- Process is a continuous loop to respond dynamically to changes in real-time (1).

准备好测试自己了吗?

将这些笔记转化为考试练习。获取此课题的无限AI题目,即时批改及详细解析。

练习此课题

卷二 Algorithms, Programming and Logic

Answer all questions in the space provided. Show all your working.
8 题目 · 73
题目 1 · Structured/Long Answer
9
A cinema booking system stores seat availability in a 2D array Seats[1:5, 1:8] of string type. Empty seats are stored as "E" and occupied seats as "O".

(a) Write a pseudocode algorithm that:
- Inputs a row number from the user.
- Validates that the input is a valid row number (1 to 5). If it is invalid, outputs an error message and prompts the user to re-enter.
- Counts and outputs the total number of empty seats in that row. [4]

(b) Explain why validation is important when using a user's input as an index for an array. [2]

(c) State three different types of test data that can be used to test the row number validation. Provide one example of test data for each type. [3]
查看答案详解

解题

(a) Pseudocode:
```
DECLARE Row, Col, Count : INTEGER
DECLARE Valid : BOOLEAN

Count <- 0
Valid <- FALSE

WHILE Valid = FALSE DO
OUTPUT "Enter a row number (1-5): "
INPUT Row
IF Row >= 1 AND Row <= 5 THEN
Valid <- TRUE
ELSE
OUTPUT "Error: Invalid row number."
ENDIF
ENDWHILE

FOR Col <- 1 TO 8 DO
IF Seats[Row, Col] = "E" THEN
Count <- Count + 1
ENDIF
NEXT Col

OUTPUT "Number of empty seats: ", Count
```

(b) Validation ensures that the input is within the bounds of the array indices (1 to 5). Without validation, if a user inputs a row number outside of this range (such as 0 or 6), it would cause an out-of-bounds array index error, leading to a runtime crash of the program.

(c)
1. Normal data: 3 (accepts valid within-range value)
2. Boundary data: 1 or 5 (accepts values on the extreme edges of the acceptable range)
3. Erroneous/Abnormal data: 6 or "A" (rejects values outside the acceptable range/wrong type)

评分标准

(a) Max 4 marks:
- 1 mark for correct validation loop (WHILE or REPEAT) with range check 1 to 5.
- 1 mark for correct prompt/error message inside or outside the loop.
- 1 mark for a FOR loop iterating from 1 to 8 to inspect columns.
- 1 mark for checking if Seats[Row, Col] equals "E" and incrementing a counter, followed by outputting the counter.

(b) Max 2 marks:
- 1 mark for identifying that it prevents out-of-bounds/index errors.
- 1 mark for explaining that this prevents a runtime error/program crash.

(c) Max 3 marks:
- 1 mark for Normal data with a valid example (e.g., 2, 3, or 4).
- 1 mark for Boundary data with a valid example (e.g., 1 or 5).
- 1 mark for Erroneous/Abnormal data with a valid example (e.g., 0, 6, "ten").
题目 2 · Structured/Long Answer
9
A database table called `TREES` stores information about specimen trees in a public botanical garden.

Fields: `TreeID` (Text), `Species` (Text), `Height` (Real), `Protected` (Boolean), `Age` (Integer).

(a) Identify the field that would be the most suitable primary key and state a reason for your choice. [2]

(b) Complete the table to show the most appropriate data type for each of the fields `Height`, `Protected`, and `Age`. [3]

(c) Write an SQL query to retrieve the `Species` and `Height` of all trees that are `Protected` and are older than 50 years, sorted by height in descending order. [4]
查看答案详解

解题

(a) `TreeID` is the most suitable primary key because it uniquely identifies each individual tree specimen in the botanical garden, preventing duplicate records.

(b)
- `Height`: Real / Decimal / Float
- `Protected`: Boolean
- `Age`: Integer

(c)
```sql
SELECT Species, Height
FROM TREES
WHERE Protected = TRUE AND Age > 50
ORDER BY Height DESC;
```

评分标准

(a) Max 2 marks:
- 1 mark for identifying `TreeID` as the primary key.
- 1 mark for stating that it uniquely identifies each tree record.

(b) Max 3 marks:
- 1 mark for `Height` -> Real / Decimal / Float.
- 1 mark for `Protected` -> Boolean.
- 1 mark for `Age` -> Integer.

(c) Max 4 marks:
- 1 mark for `SELECT Species, Height`
- 1 mark for `FROM TREES`
- 1 mark for `WHERE Protected = TRUE AND Age > 50`
- 1 mark for `ORDER BY Height DESC` (must have DESC for descending)
题目 3 · Structured/Long Answer
8
Consider the logic expression:

\(Y = \text{(A AND NOT B) OR (B XOR C)}\)

(a) Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. [4]

(b) Complete the truth table for the given logic expression: [4]

| A | B | C | Working space | Y |
|---|---|---|---|---|
| 0 | 0 | 0 | | |
| 0 | 0 | 1 | | |
| 0 | 1 | 0 | | |
| 0 | 1 | 1 | | |
| 1 | 0 | 0 | | |
| 1 | 0 | 1 | | |
| 1 | 1 | 0 | | |
| 1 | 1 | 1 | | |
查看答案详解

解题

(a) The logic circuit consists of:
- A NOT gate on input B.
- An AND gate with inputs A and NOT B.
- An XOR gate with inputs B and C.
- An OR gate combining the output of the AND gate and the XOR gate to produce Y.

(b) Truth table values for Y:
- Row 1 (0,0,0): (0 AND 1) OR (0 XOR 0) = 0 OR 0 = 0
- Row 2 (0,0,1): (0 AND 1) OR (0 XOR 1) = 0 OR 1 = 1
- Row 3 (0,1,0): (0 AND 0) OR (1 XOR 0) = 0 OR 1 = 1
- Row 4 (0,1,1): (0 AND 0) OR (1 XOR 1) = 0 OR 0 = 0
- Row 5 (1,0,0): (1 AND 1) OR (0 XOR 0) = 1 OR 0 = 1
- Row 6 (1,0,1): (1 AND 1) OR (0 XOR 1) = 1 OR 1 = 1
- Row 7 (1,1,0): (1 AND 0) OR (1 XOR 0) = 0 OR 1 = 1
- Row 8 (1,1,1): (1 AND 0) OR (1 XOR 1) = 0 OR 0 = 0

Final Y column from top to bottom: 0, 1, 1, 0, 1, 1, 1, 0.

评分标准

(a) Max 4 marks:
- 1 mark for correct NOT gate on B.
- 1 mark for correct AND gate (A AND NOT B).
- 1 mark for correct XOR gate (B XOR C).
- 1 mark for correct OR gate combining both sub-expressions to give output Y.

(b) Max 4 marks:
- 4 marks for all 8 correct values of Y.
- 3 marks for 6 or 7 correct values of Y.
- 2 marks for 4 or 5 correct values of Y.
- 1 mark for 2 or 3 correct values of Y.
题目 4 · Structured/Long Answer
8
A program uses the following pseudocode to sort an array `Numbers` containing 6 elements in descending order:

```
DECLARE Numbers : ARRAY[1:6] OF INTEGER
DECLARE Temp, I, J : INTEGER
Numbers[1] <- 14
Numbers[2] <- 3
Numbers[3] <- 25
Numbers[4] <- 8
Numbers[5] <- 19
Numbers[6] <- 2

FOR I <- 1 TO 5
FOR J <- 1 TO 6 - I
IF Numbers[J] < Numbers[J+1] THEN
Temp <- Numbers[J]
Numbers[J] <- Numbers[J+1]
Numbers[J+1] <- Temp
ENDIF
NEXT J
NEXT I
```

(a) Complete the trace table showing the contents of the array `Numbers` after each of the first three complete iterations of the outer loop (for `I = 1, 2, 3`). [6]

| Iteration I | Numbers[1] | Numbers[2] | Numbers[3] | Numbers[4] | Numbers[5] | Numbers[6] |
|---|---|---|---|---|---|---|
| Start | 14 | 3 | 25 | 8 | 19 | 2 |
| I = 1 | | | | | | |
| I = 2 | | | | | | |
| I = 3 | | | | | | |

(b) Explain why the inner loop limit decreases as the outer loop index `I` increases. [2]
查看答案详解

解题

(a) Tracing results:
- After I = 1: [14, 25, 8, 19, 3, 2]
- After I = 2: [25, 14, 19, 8, 3, 2]
- After I = 3: [25, 19, 14, 8, 3, 2]

(b) The inner loop limit decreases because after each iteration `I` of the outer loop, the `I` smallest elements are guaranteed to have bubbled to their correct final positions at the end of the array. Therefore, there is no need to compare or sort these elements again in subsequent passes.

评分标准

(a) Max 6 marks:
- 2 marks for row I = 1 correct: [14, 25, 8, 19, 3, 2]
- 2 marks for row I = 2 correct: [25, 14, 19, 8, 3, 2]
- 2 marks for row I = 3 correct: [25, 19, 14, 8, 3, 2]
(Deduct 1 mark per row for minor errors, minimum 0 per row)

(b) Max 2 marks:
- 1 mark for stating that the smallest elements are already sorted/placed at the end of the array after each pass.
- 1 mark for stating that decreasing the limit avoids redundant/unnecessary comparisons, improving efficiency.
题目 5 · Structured/Long Answer
8
An application needs to save username and score data to a text file.

(a) Explain the difference between opening a file in WRITE mode and APPEND mode. [2]

(b) Write a pseudocode algorithm that:
- Prompts the user to enter a username and score.
- Appends the entered username and score to a text file named "leaderboard.txt" in the format: `username,score`.
- Continues to prompt and append until the username entered is "END". [6]
查看答案详解

解题

(a) In WRITE mode, if the file already exists, its contents are deleted/overwritten. In APPEND mode, any new data is added to the end of the existing file, leaving current contents intact.

(b) Pseudocode:
```
DECLARE Username : STRING
DECLARE Score : INTEGER

OPEN "leaderboard.txt" FOR APPEND

OUTPUT "Enter username (or 'END' to stop): "
INPUT Username

WHILE Username <> "END" DO
OUTPUT "Enter score: "
INPUT Score
WRITEFILE "leaderboard.txt", Username, ",", Score
OUTPUT "Enter username (or 'END' to stop): "
INPUT Username
ENDWHILE

CLOSEFILE "leaderboard.txt"
```

评分标准

(a) Max 2 marks:
- 1 mark for stating WRITE mode overwrites/deletes existing content.
- 1 mark for stating APPEND mode adds new data to the end of existing content.

(b) Max 6 marks:
- 1 mark for opening "leaderboard.txt" in APPEND mode.
- 1 mark for first input of Username outside the loop (or equivalent structure).
- 1 mark for loop condition checking that Username is not "END".
- 1 mark for prompting and inputting Score inside the loop.
- 1 mark for writing Username and Score to the file separated by a comma.
- 1 mark for correct closure of the file after the loop.
题目 6 · Structured/Long Answer
8
A user registration system requires users to enter an email address.

(a) Explain the difference between validation and verification, using email address input to illustrate your answer. [4]

(b) Identify and describe two validation checks that could be applied to an email address input. [4]
查看答案详解

解题

(a) Validation is an automatic computer check to ensure that the input is sensible, reasonable, and conforms to expected rules (e.g., checking if the email contains an '@' symbol). Verification is used to check that the data entered matches the original source or is what the user intended (e.g., asking the user to enter their email twice to check if they match, preventing keying errors).

(b)
1. Presence check: Ensures that the email field cannot be left blank; it checks that some data has been entered.
2. Format check: Checks that the input pattern matches a standard email format, such as containing at least one '@' symbol and a '.' (dot) in the domain part.

评分标准

(a) Max 4 marks:
- 1 mark for defining validation as a computerized check for reasonableness/sensibility.
- 1 mark for email validation example (e.g. checking for '@' symbol).
- 1 mark for defining verification as checking if input matches source/original intent.
- 1 mark for email verification example (e.g. double entry/email matching check).

(b) Max 4 marks (2 marks per check, max 2 checks):
- 1 mark for identifying a valid check (e.g., Presence check, Format check, Length check).
- 1 mark for describing how it works in the context of email (e.g., presence check ensures not blank; format check ensures '@' is present; length check ensures it meets minimum character requirements).
题目 7 · Structured/Long Answer
8
(a) A function `calcDeliveryFee` takes two parameters: `distance` (Real) representing the delivery distance in kilometers, and `isExpress` (Boolean) representing whether express delivery is requested.

The function calculates the fee as follows:
- A base fee of $5.00 is charged.
- For every kilometer over 5 km, an additional $1.20 per kilometer is added.
- If `isExpress` is TRUE, an additional flat fee of $8.50 is added to the total.

Write a pseudocode algorithm for the function `calcDeliveryFee`. It must return the calculated fee. [5]

(b) Write a pseudocode statement to call the function `calcDeliveryFee` for a distance of 12.5 km with express delivery, storing the result in a variable named `myFee`. [3]
查看答案详解

解题

(a) Pseudocode function:
```
FUNCTION calcDeliveryFee(distance : REAL, isExpress : BOOLEAN) RETURNS REAL
DECLARE fee : REAL
fee <- 5.00

IF distance > 5.0 THEN
fee <- fee + (distance - 5.0) * 1.20
ENDIF

IF isExpress = TRUE THEN
fee <- fee + 8.50
ENDIF

RETURN fee
ENDFUNCTION
```

(b) Statement:
```
DECLARE myFee : REAL
myFee <- calcDeliveryFee(12.5, TRUE)
```

评分标准

(a) Max 5 marks:
- 1 mark for correct FUNCTION header with parameter names and types.
- 1 mark for initializing fee with the base value of 5.00.
- 1 mark for checking if `distance > 5` and correctly adding the proportional surcharge `(distance - 5) * 1.20`.
- 1 mark for checking `isExpress` and adding 8.50 if true.
- 1 mark for returning the calculated fee and ending function.

(b) Max 3 marks:
- 1 mark for declaring `myFee` as REAL / Decimal / Numeric.
- 1 mark for calling `calcDeliveryFee` with the correct argument values (`12.5` and `TRUE` or equivalent).
- 1 mark for assigning the returned value to `myFee`.
题目 8 · Programming Scenario
15
A program is required to analyze the fuel efficiency of a fleet of 50 delivery trucks.

The one-dimensional (1D) array `FuelConsumed[]` is used to store 50 real numbers representing the total fuel consumed (in liters) by each truck. The index of the array represents the Truck ID (1 to 50).

The one-dimensional (1D) array `DistanceTraveled[]` is used to store 50 real numbers representing the total distance traveled (in kilometers) by each truck.

The two-dimensional (2D) array `TruckEfficiency[]` is used to store the Truck ID and its calculated fuel efficiency (kilometers per liter).

Write a program that meets the following requirements:
- Calculate the fuel efficiency for each of the 50 trucks and store the Truck ID (1 to 50) and its calculated efficiency in the `TruckEfficiency[]` array. Fuel efficiency is calculated as: distance traveled / fuel consumed.
- Sort the contents of the `TruckEfficiency[]` array in descending order of fuel efficiency (most efficient truck first).
- Calculate the average fuel efficiency of the entire fleet.
- Output the Truck ID and efficiency for all trucks in the sorted order, along with a warning message "Review Required" for any truck whose efficiency is below 5.0 km/liter.

The following is an example of an algorithm that sorts a 2D array in ascending order based on the second column:

```
F <- TRUE
WHILE F DO
F <- FALSE
FOR I <- 1 TO 49
IF A[I, 2] > A[I + 1, 2]
THEN
T1 <- A[I, 1]
T2 <- A[I, 2]
A[I, 1] <- A[I + 1, 1]
A[I, 2] <- A[I + 1, 2]
A[I + 1, 1] <- T1
A[I + 1, 2] <- T2
F <- TRUE
ENDIF
NEXT I
ENDWHILE
```

You must use pseudocode or program code and add comments to explain how your code works.

All arrays, variables, or constants used must be declared for this algorithm. Assume the arrays `FuelConsumed[]` and `DistanceTraveled[]` have already been populated with data.

All inputs and outputs must contain suitable messages.
查看答案详解

解题

```
// Array and variable declarations
DECLARE FuelConsumed : ARRAY[1:50] OF REAL
DECLARE DistanceTraveled : ARRAY[1:50] OF REAL
DECLARE TruckEfficiency : ARRAY[1:50, 1:2] OF REAL
DECLARE Index : INTEGER
DECLARE TempID : REAL
DECLARE TempEff : REAL
DECLARE Swap : BOOLEAN
DECLARE TotalEfficiency : REAL
DECLARE AverageEfficiency : REAL

// Step 1: Calculate fuel efficiency and populate TruckEfficiency array
TotalEfficiency <- 0.0
FOR Index <- 1 TO 50
TruckEfficiency[Index, 1] <- Index
// Calculate efficiency (distance / fuel)
TruckEfficiency[Index, 2] <- DistanceTraveled[Index] / FuelConsumed[Index]
// Accumulate total efficiency to calculate average later
TotalEfficiency <- TotalEfficiency + TruckEfficiency[Index, 2]
NEXT Index

// Calculate fleet average
AverageEfficiency <- TotalEfficiency / 50.0

// Step 2: Sort the array in descending order of efficiency (column 2)
Swap <- TRUE
WHILE Swap DO
Swap <- FALSE
FOR Index <- 1 TO 49
// Check if the current efficiency is less than the next efficiency
IF TruckEfficiency[Index, 2] < TruckEfficiency[Index + 1, 2]
THEN
// Swap the Truck IDs
TempID <- TruckEfficiency[Index, 1]
TruckEfficiency[Index, 1] <- TruckEfficiency[Index + 1, 1]
TruckEfficiency[Index + 1, 1] <- TempID

// Swap the calculated efficiencies
TempEff <- TruckEfficiency[Index, 2]
TruckEfficiency[Index, 2] <- TruckEfficiency[Index + 1, 2]
TruckEfficiency[Index + 1, 2] <- TempEff

// Set swap flag to TRUE to continue the sort
Swap <- TRUE
ENDIF
NEXT Index
ENDWHILE

// Step 3: Output results with conditional warning messages
OUTPUT "Fleet Average Efficiency: ", AverageEfficiency, " km/liter"
OUTPUT "------------------------------------------------"
OUTPUT "Truck ID | Efficiency (km/L) | Status"
OUTPUT "------------------------------------------------"
FOR Index <- 1 TO 50
IF TruckEfficiency[Index, 2] < 5.0
THEN
OUTPUT TruckEfficiency[Index, 1], " | ", TruckEfficiency[Index, 2], " | Review Required"
ELSE
OUTPUT TruckEfficiency[Index, 1], " | ", TruckEfficiency[Index, 2], " | Normal"
ENDIF
NEXT Index
```

评分标准

### AO2: Apply knowledge and understanding (Max 9 marks)
- **R1: Calculating and storing efficiency** (3 marks)
- 1 mark for correct iteration loop (1 to 50) to process each truck.
- 1 mark for calculating and storing the Truck ID and fuel efficiency (distance / fuel) in the 2D array `TruckEfficiency[]`.
- 1 mark for accumulating total efficiency and calculating the correct average of the fleet.
- **R2: Sorting array in descending order** (4 marks)
- 1 mark for setting up a descending sort comparison condition (`<` instead of `>`).
- 1 mark for implementing a nested loop/flag mechanism (e.g., `WHILE Swap` and inner `FOR` loop) to traverse the array.
- 1 mark for correctly swapping both columns (Truck ID and efficiency value) to keep data synchronized.
- 1 mark for correctly updating the swap flag within the condition.
- **R3: Outputting values and handling the threshold** (2 marks)
- 1 mark for outputting the sorted efficiency list along with the fleet average.
- 1 mark for using a selection statement (`IF...THEN...ELSE`) to append "Review Required" to output if efficiency is below 5.0.

### AO3: Provide solutions, evaluate, and reason (Max 6 marks)
- **Declarations & Naming** (2 marks)
- 2 marks: All arrays, loop counters, temporary variables, and accumulators are fully declared with correct data types (e.g., `REAL`, `INTEGER`, `BOOLEAN`).
- 1 mark: Some declarations are missing or incorrect data types are used.
- **Logical Order and Comments** (2 marks)
- 2 marks: The program flows in a logical order, and relevant comments are included to explain key processing stages (calculations, sorting, conditional checks).
- 1 mark: The logic has minor gaps, or comments are sparse/not very meaningful.
- **User-friendly Outputs** (2 marks)
- 2 marks: Fully structured output displays, with clear labels and suitable descriptive text.
- 1 mark: Output statements are present but minimal or lack formatting/context.

想知道自己有几分把握?

thinka 是 DSE 学生在用的 AI 练习应用,提供无限量练习题、即时自动批改和详细解题步骤。超过 100,000 名学生用它确认自己是真的会,而不只是「以为会」。

想练更多同类题型?在 thinka 无限量刷题,即时知道答案。

免费开始练习