Cambridge IGCSE · thinka 原创模拟试题

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

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

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

卷一 Computer Systems

Answer all questions. Calculators must not be used.
24 题目 · 74
题目 1 · Short Answer
2
State two reasons why programmers use hexadecimal notation instead of binary notation to represent data.
查看答案详解

解题

Hexadecimal representations are significantly shorter and more compact than equivalent binary representations, which makes them easier for programmers to read, write, and remember. Furthermore, because there are fewer characters to enter, programmers are far less likely to make typing/transcription errors.

评分标准

Award 1 mark for each valid reason up to a maximum of 2 marks:
- Easier for programmers to read/write/remember
- Less prone to typing or transcription errors
- Easier to debug/spot patterns
题目 2 · Short Answer
2
Describe the effect that increasing the sample rate has on a recorded sound file.
查看答案详解

解题

Increasing the sample rate means more measurements of the analog sound wave are captured per second. This results in a more accurate digital representation of the sound (higher quality/fidelity). However, because more data points are recorded and stored, the file size of the sound file increases.

评分标准

Award 1 mark for effect on sound quality:
- Sound reproduction is higher quality // more accurate to original analog wave // wider frequency range captured
Award 1 mark for effect on resources:
- File size of the recording increases // requires more storage space or transmission bandwidth
题目 3 · Short Answer
2
State two reasons why a programmer might choose to write code in a low-level language, such as assembly language, rather than a high-level language.
查看答案详解

解题

A programmer may choose assembly language to gain direct manipulation over CPU registers and system hardware. Additionally, low-level programs can be highly optimized to execute much faster and require less memory storage than programs written in high-level languages.

评分标准

Award 1 mark for each valid reason up to a maximum of 2 marks:
- Allows direct control/manipulation of hardware/CPU registers/input-output ports
- Code can be optimized to execute more quickly
- Code requires less memory/storage space
- Can write code directly suited for embedded controllers/real-time systems
题目 4 · Short Answer
2
State two distinct functions of the Control Unit (CU) within the Central Processing Unit (CPU).
查看答案详解

解题

The Control Unit (CU) manages the components of the CPU during the Fetch-Decode-Execute cycle. Its functions include decoding the instructions fetched from memory to determine what operation to perform, and directing/coordinating the flow of control and data signals between the CPU components (such as the ALU and registers).

评分标准

Award 1 mark for each distinct function up to a maximum of 2 marks:
- Decodes instructions (during the FDE cycle)
- Controls/directs the flow of data/signals within the CPU
- Coordinates and synchronizes instructions using the system clock
- Sends control signals to other registers/components (e.g., ALU, memory)
题目 5 · Short Answer
2
Explain how a checksum is used to detect errors in transmitted data.
查看答案详解

解题

Before data is sent, the sender applies an algorithm to the block of data to calculate a numerical value known as a checksum, which is appended to the payload. Upon arrival, the receiver performs the same calculation on the incoming data. If the recalculated checksum matches the received checksum, the data is assumed to be error-free; if they differ, an error has occurred.

评分标准

Award 1 mark for generation/sending phase:
- Checksum is calculated from the block of data using a formula/algorithm prior to transmission and sent alongside the data.
Award 1 mark for verification/comparison phase:
- The receiving computer recalculates the checksum and compares it with the sent checksum; a mismatch signals a transmission error has occurred.
题目 6 · Short Answer
2
In the context of robotic systems, explain the difference between a sensor and an actuator.
查看答案详解

解题

A sensor acts as an input device that detects and measures physical properties or changes in the environment (such as light levels, temperature, or distance) and sends this data to the robotic controller. An actuator is an output device that converts electrical signals from the controller into physical movement or action (such as turning a wheel or closing a gripper).

评分标准

Award 1 mark for correct description of a sensor:
- Sensor: Input device that measures or detects environmental physical variables and sends data/signals to the processor.
Award 1 mark for correct description of an actuator:
- Actuator: Output device that carries out mechanical actions, physical movements, or structural adjustments based on signals from the processor.
题目 7 · Short Answer
2
Explain the difference between phishing and pharming.
查看答案详解

解题

Phishing is a social engineering attack where a user is sent fraudulent messages (like emails) containing links designed to trick them into navigating to a fake website and entering credentials. Pharming is a malicious software or system attack where DNS server records or local host files are manipulated, causing the user to be automatically redirected to a fake website even when they type the correct URL in their browser.

评分标准

Award 1 mark for phishing explanation:
- Phishing: Uses spam/deceptive emails or messages with fake links to trick users into giving away personal details.
Award 1 mark for pharming explanation:
- Pharming: Infects computers or DNS servers with malicious code to automatically redirect users to fake sites (independent of clicking an email link).
题目 8 · Short Answer
2
Explain the purpose of an interrupt in a computer system.
查看答案详解

解题

An interrupt is a signal generated by hardware or software sent to the CPU, requesting immediate attention. It allows the CPU to temporarily suspend its current execution cycle, save its progress, handle the urgent event (such as disk input/output or device errors) via an Interrupt Service Routine (ISR), and then resume the original task.

评分标准

Award 1 mark for signal/halting aspect:
- A signal sent from hardware/software to suspend/interrupt the CPU's current execution cycle.
Award 1 mark for handling/multitasking aspect:
- Enables the system to respond efficiently to urgent/asynchronous events (using Interrupt Service Routines) and then return to original tasks.
题目 9 · Mathematical Conversion & Logic
3
A security system stores an error code as an 8-bit signed binary integer using two's complement representation. The error code is -43 in denary. Convert the denary value -43 into its 8-bit two's complement binary representation. Show your working.
查看答案详解

解题

First, convert the positive value 43 to 8-bit binary: 43 = 32 + 8 + 2 + 1, which is 00101011. Next, perform the one's complement by inverting all the bits to get 11010100. Finally, add 1 to the result to get the two's complement: 11010100 + 1 = 11010101.

评分标准

1 mark for correct binary representation of positive 43 (00101011). 1 mark for showing correct method of working (e.g. inverting the bits or subtracting from 256). 1 mark for correct final 8-bit two's complement value (11010101).
题目 10 · Mathematical Conversion & Logic
3
An IPv6 address block contains the hexadecimal value C4B. Convert this hexadecimal value into a 12-bit binary number. Show your working.
查看答案详解

解题

Convert each individual hexadecimal digit into its 4-bit binary equivalent: C in hexadecimal is 12 in denary, which is 1100 in binary. 4 in hexadecimal is 4 in denary, which is 0100 in binary. B in hexadecimal is 11 in denary, which is 1011 in binary. Combining these yields: 110001001011.

评分标准

1 mark for correct binary conversion of C (1100). 1 mark for correct binary conversion of 4 (0100). 1 mark for correct binary conversion of B (1011).
题目 11 · Mathematical Conversion & Logic
3
Add the two 8-bit unsigned binary numbers 01101100 and 01010011. Give your answer in binary. Show all your working, including carry bits.
查看答案详解

解题

Align the values: 01101100 + 01010011. Working from right to left: 0+1=1, 0+1=1, 1+0=1, 1+0=1, 0+1=1, 1+0=1, 1+1=0 with carry 1, 0+0+1(carry)=1. The final combined binary string is 10111111.

评分标准

1 mark for showing correct carry bits or demonstrating a valid addition method. 1 mark for correct right nibble (1111). 1 mark for correct left nibble (1011).
题目 12 · Mathematical Conversion & Logic
3
Consider the logic expression: X = (A AND NOT B) OR (B XOR C). Calculate the value of X when the input values are: A = 1, B = 1, C = 0. Show each step of your working.
查看答案详解

解题

Substitute the inputs into the expression: X = (1 AND NOT 1) OR (1 XOR 0). Step 1: Evaluate the left term: NOT 1 = 0, so (1 AND 0) = 0. Step 2: Evaluate the right term: (1 XOR 0) = 1. Step 3: Combine the two terms using OR: 0 OR 1 = 1.

评分标准

1 mark for evaluating the left term (A AND NOT B) as 0. 1 mark for evaluating the right term (B XOR C) as 1. 1 mark for the correct final value of X as 1.
题目 13 · Mathematical Conversion & Logic
3
A digital camera captures an image with a resolution of 1024 pixels by 512 pixels. The image is stored with a colour depth of 8 bits per pixel. Calculate the file size of the image in kibibytes (KiB). Show your working.
查看答案详解

解题

Total pixels = 1024 * 512 = 524288 pixels. With a colour depth of 8 bits (which equals 1 byte) per pixel, the total file size in bytes is 524288 bytes. To convert bytes to kibibytes, divide by 1024: 524288 / 1024 = 512 KiB.

评分标准

1 mark for calculating the total pixels or showing the correct multiplication formula. 1 mark for showing division by 1024 to convert bytes to KiB. 1 mark for correct final answer of 512.
题目 14 · Mathematical Conversion & Logic
3
A system uses even parity to transmit 7-bit ASCII characters with a parity bit in the most significant bit (MSB) position. The following three bytes are received: Byte 1: 01101010, Byte 2: 10011100, Byte 3: 11100011. Identify which byte contains an error and explain how you determined this.
查看答案详解

解题

Even parity means each byte must contain an even number of 1s. Let's count the number of 1s in each byte: Byte 1 (01101010) has four 1s (even, valid). Byte 2 (10011100) has five 1s (odd, invalid). Byte 3 (11100011) has six 1s (even, valid). Therefore, Byte 2 contains a transmission error.

评分标准

1 mark for identifying Byte 2 contains the error. 1 mark for explaining that Byte 2 has an odd number of 1s (5 ones). 1 mark for stating that a valid byte must contain an even number of 1s because the system uses even parity.
题目 15 · Structured Explanation & Comparison
4
An image file has a resolution of 1920 by 1080 pixels and a colour depth of 24 bits. Compare the effects on file size and image quality of decreasing the colour depth to 8 bits versus decreasing the resolution to 960 by 540 pixels while keeping the original colour depth.
查看答案详解

解题

Decreasing colour depth to 8 bits reduces the number of bits stored per pixel, lowering the overall file size. However, it severely limits the colour palette to 256 colours, resulting in colour banding and lower quality. Decreasing the resolution to 960 by 540 reduces the total number of pixels by 75% (to a quarter of the original count), which drastically reduces the file size. However, the image will lose fine details and look pixelated if displayed on high-resolution screens.

评分标准

1 mark: Explaining that reducing colour depth to 8 bits reduces file size by reducing bits per pixel. 1 mark: Explaining the quality impact of 8-bit depth (reduction to 256 colours causing colour banding). 1 mark: Explaining that reducing resolution to 960x540 significantly reduces file size because the total pixel count drops by 75 percent. 1 mark: Explaining the quality impact of lower resolution (loss of fine details and pixelation when scaled up).
题目 16 · Structured Explanation & Comparison
4
Compare a Solid State Drive (SSD) with a Hard Disk Drive (HDD) as secondary storage. Your comparison must explain two distinct advantages of using an SSD over an HDD, and two distinct advantages of using an HDD over an SSD.
查看答案详解

解题

Solid State Drives (SSDs) use flash memory and have no moving parts, which provides faster read/write times and greater physical durability against shocks compared to Hard Disk Drives (HDDs). On the other hand, HDDs use magnetic platters and read/write heads, making them cheaper per gigabyte and offering longer write endurance, as SSD flash cells degrade over multiple write cycles.

评分标准

1 mark per valid SSD advantage (max 2): faster read/write speeds, lower power consumption, silent operation, high physical durability. 1 mark per valid HDD advantage (max 2): lower cost per gigabyte, higher read/write cycle endurance, easier data recovery from damaged drives.
题目 17 · Structured Explanation & Comparison
4
A software engineer can use either a compiler or an interpreter to translate code written in a high-level language. Describe two differences in how a compiler and an interpreter translate high-level code, and explain how these differences impact the debugging process for the developer.
查看答案详解

解题

A compiler translates the entire source code into machine code all at once, creating an executable file before execution starts, whereas an interpreter translates and executes the source code line-by-line in real time. For debugging, a compiler produces a complete list of syntax errors only after attempting to compile the whole program, which can make debugging harder as the developer must look at multiple errors at once. Conversely, an interpreter stops execution the moment it encounters an error on a specific line, making it much easier to pinpoint and resolve runtime bugs dynamically.

评分标准

1 mark: Explaining that a compiler translates the entire code at once while an interpreter translates and executes line-by-line. 1 mark: Explaining that a compiler produces an executable file whereas an interpreter runs the source code directly. 1 mark: Explaining that a compiler's error report is only produced at the end of translation, listing all syntax errors. 1 mark: Explaining that an interpreter stops execution immediately at an error, easing line-by-line debugging.
题目 18 · Structured Explanation & Comparison
4
Data transmitted over a network can be protected using encryption. Compare symmetric encryption with asymmetric encryption. Your explanation must include how keys are used in both methods and why asymmetric encryption is generally considered more secure for sharing data over the internet.
查看答案详解

解题

Symmetric encryption uses one single secret key that both the sender and receiver must possess to encrypt and decrypt the message. Asymmetric encryption uses a mathematically linked key pair: a public key (shared openly) to encrypt the message, and a private key (kept secret by the owner) to decrypt it. Asymmetric encryption is more secure for the internet because the private key never needs to be sent across the network, avoiding the risk of key interception that exists when exchanging a symmetric key.

评分标准

1 mark: Explaining that symmetric encryption uses the same single key for encryption and decryption. 1 mark: Explaining that asymmetric encryption uses a public key to encrypt and a private key to decrypt. 1 mark: Identifying the risk of key exchange in symmetric encryption (intercepted key compromises everything). 1 mark: Explaining that asymmetric encryption resolves this because the decryption key (private key) is never transmitted.
题目 19 · Structured Explanation & Comparison
4
Data transmission can lead to errors. Two methods used to detect these errors are parity checks and check digits. Compare the use of a parity check with the use of a check digit. Your answer must explain how each method functions and highlight one limitation of a parity check that is resolved by using a check digit.
查看答案详解

解题

A parity check allocates an extra bit (parity bit) to a byte of data before transmission to make the total count of 1s either even or odd. The receiving device counts the 1s to detect single-bit transmission errors. A check digit is calculated using an algorithm (such as Luhn's or modulo 11) on a numerical sequence and is appended to the data; it is recalculated upon data entry to verify its integrity. A key limitation of parity check is that it cannot detect transposition errors or an even number of swapped bits. A check digit resolves this because the algorithm applies unique positional weights, ensuring that swapped adjacent digits are flagged.

评分标准

1 mark: Describing how parity checks work (adding a parity bit to make 1s count even or odd). 1 mark: Describing how check digits work (calculated on a sequence of digits using an algorithm and appended). 1 mark: Explaining the parity check limitation (cannot detect an even number of bit changes or transposition). 1 mark: Explaining how check digits resolve transposition errors due to weighted algorithms.
题目 20 · Structured Explanation & Comparison
4
Computer software is broadly categorized into system software and application software. Define both types of software and explain, using a practical example for each, how they differ in their primary purpose.
查看答案详解

解题

System software consists of files and programs that manage and control the computer's hardware and resources directly, ensuring the system operates efficiently. An example is the Operating System (e.g., macOS) or utility software (e.g., disk defragmenter). Application software consists of programs designed to allow the end-user to perform specific activities or tasks. Examples include Web Browsers (e.g., Chrome) and Word Processors (e.g., MS Word). The main difference in purpose is that system software works in the background to keep the hardware functioning, while application software acts as a productivity tool for the user's specific goals.

评分标准

1 mark: Defining system software as programs managing the hardware and system performance. 1 mark: Providing a correct example of system software (OS, compilers, device drivers, utilities). 1 mark: Defining application software as programs designed for users to complete specific tasks. 1 mark: Providing a correct example of application software (word processor, web browser, spreadsheets).
题目 21 · Structured Explanation & Comparison
4
In a computer system based on the Von Neumann architecture, the Central Processing Unit (CPU) contains several registers. Describe the role of the Memory Address Register (MAR) and the Memory Data Register (MDR) during the Fetch-Decode-Execute cycle, and explain how they interact with each other.
查看答案详解

解题

The Memory Address Register (MAR) is used to store the address of the memory location (in RAM) currently being accessed for a read or write operation. The Memory Data Register (MDR) stores the actual data or instruction that is read from or about to be written to that address. During a read operation, the address of the required instruction is copied from the Program Counter to the MAR. The MAR sends this address along the address bus to memory, and the data stored at that address is sent back along the data bus, where it is stored in the MDR before being decoded.

评分标准

1 mark: Describing MAR role (storing the memory address currently being read from or written to). 1 mark: Describing MDR role (storing the data or instruction fetched from RAM or waiting to be written). 1 mark: Explaining the read interaction (address in MAR is used to locate data, which is then copied into MDR). 1 mark: Specifying the use of buses in this interaction (address bus used by MAR, data bus used by MDR).
题目 22 · Structured Explanation & Comparison
4
An automated greenhouse uses a robotic system to control the environment (such as temperature and soil moisture). Explain the roles of sensors and actuators in this robotic system, and describe how they work together with a microprocessor to automate the care of the plants.
查看答案详解

解题

Sensors continuously measure environmental conditions (e.g., temperature, moisture) and convert these physical readings into electrical signals, which are converted to digital data using an ADC and sent to the microprocessor. Actuators are physical mechanical devices (e.g., motors, valves, heaters) that perform actions to alter the physical environment. The microprocessor continuously compares the incoming sensor readings with predefined optimal threshold values. If a sensor value exceeds or drops below a threshold, the microprocessor sends a control signal to the corresponding actuator (e.g., opening a window motor or turning on a water pump) to restore conditions to normal, completing a feedback loop.

评分标准

1 mark: Describing the role of sensors in taking continuous physical readings and sending them to the CPU (with ADC conversion). 1 mark: Describing the role of actuators in performing mechanical work to alter the environment. 2 marks: Explaining the feedback interaction (microprocessor compares data against preset thresholds; if outside limits, it commands the actuators to trigger an adjustment).
题目 23 · structured
4
A manufacturer is designing a new portable tablet computer. They are deciding whether to use a Solid State Drive (SSD) or a Magnetic Hard Disk Drive (HDD) for secondary storage.

Explain two reasons why the manufacturer should choose an SSD rather than an HDD for this portable tablet computer.
查看答案详解

解题

An SSD is superior for a portable tablet because:
1. It lacks moving parts, providing high physical durability and impact resistance when dropped.
2. It has low energy consumption, preserving battery charge for mobile use.
3. It is much lighter and smaller in size, allowing the tablet to remain thin and lightweight.
4. It has much faster read/write speeds, enabling faster boot-up and application loading times.

评分标准

Max 4 marks. Award up to 2 marks per reason (1 mark for identifying a valid advantage of SSDs compared to HDDs, and 1 mark for explaining why this is beneficial specifically for a portable tablet computer):

- SSDs have no moving parts / are more durable / robust (1 mark)
- ...so they are less likely to be damaged when dropped or carried around (1 mark)
- SSDs consume less power / are more energy-efficient (1 mark)
- ...which extends the battery life of the tablet (1 mark)
- SSDs are lighter / physically smaller (1 mark)
- ...which helps keep the tablet thin and lightweight (1 mark)
- SSDs have faster read/write/access speeds (1 mark)
- ...allowing the device to boot up and load apps much faster (1 mark)
题目 24 · structured
4
A company wants to securely transmit confidential client data over the internet. They are choosing between symmetric encryption and asymmetric encryption.

Explain how asymmetric encryption differs from symmetric encryption. Your explanation must include references to how keys are used in both methods.
查看答案详解

解题

Symmetric encryption uses only one private key for both encryption and decryption. This key must be securely shared. Asymmetric encryption uses two separate but linked keys: a public key, which is made public to allow encryption, and a private key, which is kept completely secret and used to decrypt.

评分标准

Award 1 mark per point up to a maximum of 4 marks:
- Symmetric encryption uses a single/same key for both encryption and decryption (1 mark)
- This single key must be shared/exchanged, which creates a security risk if intercepted (1 mark)
- Asymmetric encryption uses a key pair consisting of a public key and a private key (1 mark)
- The public key is widely available and is used only to encrypt the data (1 mark)
- The private key is kept secret/private by the receiver and is used to decrypt the data (1 mark)
- Asymmetric encryption is more secure because the decryption key is never transmitted or shared (1 mark)

准备好测试自己了吗?

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

练习此课题

卷二 Algorithms, Programming and Logic

Answer all questions. Calculators must not be used. Note: Question 10 (15 marks) has been removed.
11 题目 · 40
题目 1 · matching
3
A smart greenhouse system monitors temperature and humidity to decide if the automatic ventilation system should be turned on.

After the task is decomposed, there are three component parts: **input**, **process**, and **output**.

Match each component part to its most appropriate relevant description.

**Component Part:**
- Input
- Process
- Output

**Descriptions:**
- A: The system reads values from the temperature sensor and the humidity sensor.
- B: The system compares the recorded temperature against a threshold value of 30°C.
- C: The ventilation fan is switched on to cool the greenhouse.
- D: The physical dimensions of the greenhouse ventilation fan.
查看答案详解

解题

- **Input** matches **A** because reading sensor data (temperature and humidity) is the phase where data is received by the system.
- **Process** matches **B** because comparing the values against a threshold is a computation/decision-making step.
- **Output** matches **C** because turning on the physical fan is the action or result produced by the system.
- **D** is not used as it is irrelevant to the active components of decomposition.

评分标准

One mark for each correct match, up to a maximum of 3 marks:
- Input matched with A (1 mark)
- Process matched with B (1 mark)
- Output matched with C (1 mark)
题目 2 · matching
3
An automated toll booth system calculates the charge for vehicles based on their weight and classification.

After the task is decomposed, there are three component parts: **input**, **process**, and **output**.

Match each component part to its most appropriate relevant description.

**Component Part:**
- Input
- Process
- Output

**Descriptions:**
- A: The vehicle classification and weight are captured when the vehicle passes over the sensor.
- B: The system calculates the price of the toll using the vehicle's weight and class.
- C: The toll fee is displayed on the screen and the barrier gate is opened.
- D: The total number of lanes available at the toll plaza.
查看答案详解

解题

- **Input** matches **A** because capturing vehicle details and weight is the retrieval of data.
- **Process** matches **B** because calculating the toll price using an algorithm is the manipulation/processing of data.
- **Output** matches **C** because displaying the fee and opening the barrier gate is the system's output response.
- **D** is an unused description because the number of lanes is an environmental attribute, not a dynamic functional part of the decomposed transaction.

评分标准

One mark for each correct match, up to a maximum of 3 marks:
- Input matched with A (1 mark)
- Process matched with B (1 mark)
- Output matched with C (1 mark)
题目 3 · matching
3
A fitness tracker calculates the number of calories burned by a user during a workout.

After the task is decomposed, there are three component parts: **input**, **process**, and **output**.

Match each component part to its most appropriate relevant description.

**Component Part:**
- Input
- Process
- Output

**Descriptions:**
- A: The user's weight, workout duration, and average heart rate are retrieved from user settings and sensors.
- B: The calorie burn rate is calculated using the formula: weight * duration * (heart rate / 100).
- C: The total calorie count is updated and displayed on the tracker's screen.
- D: The color of the silicone wristband of the tracker.
查看答案详解

解题

- **Input** matches **A** because retrieving weight, duration, and heart rate values provides the raw data required for calculation.
- **Process** matches **B** because computing the calories burned using the mathematical formula is the processing stage.
- **Output** matches **C** because displaying the final calculated results on the screen represents the output stage.
- **D** is not used because the color of the wristband is an irrelevant aesthetic detail (abstraction removes this).

评分标准

One mark for each correct match, up to a maximum of 3 marks:
- Input matched with A (1 mark)
- Process matched with B (1 mark)
- Output matched with C (1 mark)
题目 4 · short_answer
4
The 1D array `Temp` contains 6 temperature values:
- `Temp[1] = -2`
- `Temp[2] = -5`
- `Temp[3] = 3`
- `Temp[4] = -1`
- `Temp[5] = -4`
- `Temp[6] = -3`

Consider the following pseudocode algorithm:

```text
DECLARE Temp : ARRAY[1:6] OF INTEGER
DECLARE Count, MaxRun, CurrentRun, Index : INTEGER

MaxRun ← 0
CurrentRun ← 0
FOR Index ← 1 TO 6
IF Temp[Index] < 0
THEN
CurrentRun ← CurrentRun + 1
IF CurrentRun > MaxRun
THEN
MaxRun ← CurrentRun
ENDIF
ELSE
CurrentRun ← 0
ENDIF
NEXT Index
OUTPUT "Max frost run: ", MaxRun
```

Complete the trace table for this algorithm.
查看答案详解

解题

Let us trace the algorithm step-by-step:
1. Initialize `MaxRun ← 0` and `CurrentRun ← 0`.
2. `Index = 1`: `Temp[1] = -2 < 0` is True. `CurrentRun` becomes `1`. Since `1 > 0`, `MaxRun` becomes `1`.
3. `Index = 2`: `Temp[2] = -5 < 0` is True. `CurrentRun` becomes `2`. Since `2 > 1`, `MaxRun` becomes `2`.
4. `Index = 3`: `Temp[3] = 3 < 0` is False. `CurrentRun` becomes `0`.
5. `Index = 4`: `Temp[4] = -1 < 0` is True. `CurrentRun` becomes `1`. Since `1 > 2` is False, `MaxRun` remains `2`.
6. `Index = 5`: `Temp[5] = -4 < 0` is True. `CurrentRun` becomes `2`. Since `2 > 2` is False, `MaxRun` remains `2`.
7. `Index = 6`: `Temp[6] = -3 < 0` is True. `CurrentRun` becomes `3`. Since `3 > 2` is True, `MaxRun` becomes `3`.
8. After the loop, the algorithm outputs: `"Max frost run: ", 3`.

评分标准

One mark per correct column or sequence:
- MP1: Correct `Index` values from 1 to 6 in order.
- MP2: Correct trace of `CurrentRun` updates (`1`, `2`, `0`, `1`, `2`, `3`).
- MP3: Correct trace of `MaxRun` updates (changing to `1`, then `2`, then staying empty/unchanged until updating to `3` on the final step).
- MP4: Correct output message `"Max frost run: 3"` on the final line (or similar representation).
题目 5 · short_answer
5
Consider the following pseudocode algorithm designed to calculate a weighted checksum digit for a 4-digit code:

```text
DECLARE Code, Digit, Sum, Weight : INTEGER
INPUT Code
Sum ← 0
Weight ← 4
WHILE Code > 0 DO
Digit ← Code MOD 10
Sum ← Sum + (Digit * Weight)
Code ← Code DIV 10
Weight ← Weight - 1
ENDWHILE
OUTPUT "Checksum: ", Sum
```

Complete the trace table for the algorithm when the input value for `Code` is `3524`.
查看答案详解

解题

Let us trace the loop iterations with the initial input `Code = 3524`:
- Initial state: `Sum = 0`, `Weight = 4`.
- **Iteration 1**:
- `Digit ← 3524 MOD 10 = 4`
- `Sum ← 0 + (4 * 4) = 16`
- `Code ← 3524 DIV 10 = 352`
- `Weight ← 4 - 1 = 3`
- **Iteration 2**:
- `Digit ← 352 MOD 10 = 2`
- `Sum ← 16 + (2 * 3) = 22`
- `Code ← 352 DIV 10 = 35`
- `Weight ← 3 - 1 = 2`
- **Iteration 3**:
- `Digit ← 35 MOD 10 = 5`
- `Sum ← 22 + (5 * 2) = 32`
- `Code ← 35 DIV 10 = 3`
- `Weight ← 2 - 1 = 1`
- **Iteration 4**:
- `Digit ← 3 MOD 10 = 3`
- `Sum ← 32 + (3 * 1) = 35`
- `Code ← 3 DIV 10 = 0`
- `Weight ← 1 - 1 = 0`
- The loop terminates since `Code > 0` is now False (`Code = 0`).
- Output: `"Checksum: 35"`.

评分标准

Marking breakdown (5 marks total):
- MP1: Correct initial row setup with Code as `3524`, Sum as `0`, and Weight as `4`.
- MP2: Correct trace of the `Digit` column sequence (`4`, `2`, `5`, `3`).
- MP3: Correct trace of the decreasing `Code` values (`352`, `35`, `3`, `0`).
- MP4: Correct trace of the accumulating `Sum` values (`16`, `22`, `32`, `35`) and `Weight` decreases (`3`, `2`, `1`, `0`).
- MP5: Correct final output `"Checksum: 35"` recorded below the main processing loops.
题目 6 · Pseudocode Logic Corrections
4
A programmer has written a pseudocode algorithm intended to find the average score of students who passed an exam (score of 50 or above) from a group of 100 students. The scores are already stored in an array, `Scores`.

```pseudocode
01 DECLARE Scores : ARRAY[1:100] OF INTEGER
02 DECLARE PassTotal : INTEGER
03 DECLARE PassCount : INTEGER
04 DECLARE AveragePass : REAL
05 PassTotal <- 0
06 PassCount <- 1
07 FOR Index <- 1 TO 100
08 INPUT Scores[Index]
09 IF Scores[Index] > 50
10 THEN
11 PassTotal <- Scores[Index]
12 PassCount <- PassCount + 1
13 ENDIF
14 NEXT Index
15 AveragePass <- PassTotal / 100
16 OUTPUT "The average score of passing students is: ", AveragePass
```

Identify the line numbers of four logic errors in this pseudocode and suggest a correction for each.
查看答案详解

解题

Error 1: Line 06
Correction: `PassCount <- 0`

Error 2: Line 09
Correction: `IF Scores[Index] >= 50`

Error 3: Line 11
Correction: `PassTotal <- PassTotal + Scores[Index]`

Error 4: Line 15
Correction: `AveragePass <- PassTotal / PassCount`

评分标准

1 mark per correct line number and corresponding correction, up to a maximum of 4 marks.
- Line 06 correction: PassCount should be initialized to 0.
- Line 09 correction: Condition should check >= 50 instead of > 50.
- Line 11 correction: Scores should be accumulated rather than overwritten (PassTotal <- PassTotal + Scores[Index]).
- Line 15 correction: Total score should be divided by PassCount instead of 100.
题目 7 · Pseudocode Writing
4
A 1D array named `Temp` contains 50 temperature readings.

Write a pseudocode algorithm to find and output the largest difference between any two consecutive readings in the array. You must declare any variables used and provide comments to explain your logic.
查看答案详解

解题

```pseudocode
DECLARE MaxDiff : INTEGER
DECLARE Diff : INTEGER
DECLARE Index : INTEGER
MaxDiff <- 0
// Loop through the array comparing each element with the next
FOR Index <- 1 TO 49
Diff <- ABS(Temp[Index] - Temp[Index + 1])
// Check if the current difference is larger than the maximum found so far
IF Diff > MaxDiff
THEN
MaxDiff <- Diff
ENDIF
NEXT Index
OUTPUT "The largest difference is: ", MaxDiff
```

评分标准

One mark per mark point, max four:
- MP1: Correct variable declarations for `MaxDiff`, `Diff`, and `Index`.
- MP2: A loop running from 1 to 49 to process consecutive element pairs.
- MP3: Correct calculation of absolute difference between `Temp[Index]` and `Temp[Index + 1]`.
- MP4: Selection statement checking if current difference is greater than `MaxDiff` and updating `MaxDiff` accordingly, with final output of the maximum difference.
题目 8 · Pseudocode Logic Corrections
4
The following pseudocode is designed to count the number of times a target character appears in a given string.

```pseudocode
01 DECLARE Phrase : STRING
02 DECLARE Target : CHAR
03 DECLARE Count : INTEGER
04 DECLARE Length : INTEGER
05 DECLARE Index : INTEGER
06 INPUT Phrase
07 INPUT Target
08 Count <- 0
09 Length <- LENGTH(Phrase)
10 FOR Index <- 0 TO Length
11 IF SUBSTRING(Phrase, 1, Index) = Target
12 THEN
13 Count <- Count + Index
14 ENDIF
15 NEXT Index
16 OUTPUT "Total occurrences: ", Target
```

Identify the line numbers of four logic errors in this pseudocode and suggest a correction for each.
查看答案详解

解题

Error 1: Line 10
Correction: `FOR Index <- 1 TO Length`

Error 2: Line 11
Correction: `IF SUBSTRING(Phrase, Index, 1) = Target`

Error 3: Line 13
Correction: `Count <- Count + 1`

Error 4: Line 16
Correction: `OUTPUT "Total occurrences: ", Count`

评分标准

One mark per correct error and correction:
- Line 10: In 1-indexed string representation, the loop must start at index 1 instead of 0.
- Line 11: The parameters for SUBSTRING should be `Phrase, Index, 1` to inspect one character at a time.
- Line 13: Increment count by 1 instead of adding `Index`.
- Line 16: Output the value of the `Count` variable instead of the search character `Target`.
题目 9 · Pseudocode Writing
4
An array, `Names`, contains 100 elements sorted in alphabetical order.

Write a pseudocode algorithm to search the array for a given name input by the user, `SearchName`. The search must stop as soon as the name is found, and output either the position (index) where the name was found, or a message stating "Name not found" if it does not exist in the array.
查看答案详解

解题

```pseudocode
DECLARE Found : BOOLEAN
DECLARE Index : INTEGER
DECLARE SearchName : STRING

INPUT SearchName
Found <- FALSE
Index <- 1

WHILE Found = FALSE AND Index <= 100 DO
IF Names[Index] = SearchName
THEN
Found <- TRUE
ELSE
Index <- Index + 1
ENDIF
ENDWHILE

IF Found = TRUE
THEN
OUTPUT "Name found at index: ", Index
ELSE
OUTPUT "Name not found"
ENDIF
```

评分标准

One mark per mark point, max four:
- MP1: Initialization of `Found` to `FALSE` and `Index` to 1.
- MP2: `WHILE` loop with correct conditional expression `Found = FALSE AND Index <= 100`.
- MP3: Correct comparison inside the loop, updating `Found` to `TRUE` if matches, otherwise incrementing `Index`.
- MP4: Conditional statement after the loop to output the search results correctly.
题目 10 · fill-in-the-blank
3
A database table, `SpaceMission`, stores data about robotic space exploration missions. The table contains these fields: `MissionID`, `Name`, `Destination`, `LaunchYear`, `Cost`, `Success`.

Complete the SQL query to retrieve the name and destination fields for all successful space missions (where the `Success` field is true).

`SELECT` [Blank 1]
`FROM SpaceMission`
`WHERE` [Blank 2] `= ` [Blank 3] `;`
查看答案详解

解题

To retrieve the name and destination of the missions, we use `SELECT Name, Destination`.
To filter for successful missions, the WHERE clause must check if the `Success` field is equal to `TRUE` (or `True` / `1`).

The completed statement is:
`SELECT Name, Destination`
`FROM SpaceMission`
`WHERE Success = TRUE;`

评分标准

One mark for each correct answer:
- [Blank 1]: Name, Destination (both fields required, any order)
- [Blank 2]: Success
- [Blank 3]: TRUE (accept True or 1)
题目 11 · fill-in-the-blank
3
A database table, `BookInventory`, stores data about books in a local store. The fields are: `ISBN`, `Title`, `Author`, `Genre`, `Price`, `StockLevel`.

Complete the SQL statement to display the titles and prices of all books belonging to the 'Sci-Fi' genre, sorted in descending order of price.

`SELECT Title, Price`
`FROM BookInventory`
`WHERE` [Blank 1] `= ` [Blank 2]
`ORDER BY` [Blank 3] `;`
查看答案详解

解题

We need to filter by the `Genre` field being equal to `'Sci-Fi'`. Thus [Blank 1] is `Genre` and [Blank 2] is `'Sci-Fi'` (enclosed in single or double quotes to indicate text value).
We need to sort the results in descending order of price, so [Blank 3] is `Price DESC`.

The complete statement is:
`SELECT Title, Price`
`FROM BookInventory`
`WHERE Genre = 'Sci-Fi'`
`ORDER BY Price DESC;`

评分标准

One mark for each correct answer:
- [Blank 1]: Genre
- [Blank 2]: 'Sci-Fi' or "Sci-Fi" (do not accept Sci-Fi without quotes)
- [Blank 3]: Price DESC (accept DESCENDING or desc)

想知道自己有几分把握?

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

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

免费开始练习