Cambridge IGCSE · Thinka 原創模擬試題

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

Thinka Nov 2024 (V1) Cambridge International A Level-Style Mock — Computer Science (0478)

150 210 分鐘2024
An original Thinka practice paper modelled on the structure and difficulty of the Nov 2024 (V1) Cambridge International A Level Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.

Paper 11 Computer Systems

Answer all questions. Calculators must not be used.
9 題目 · 60
題目 1 · short_answer
5
Identify the CPU register or component in the Von Neumann architecture described by each of the following statements: 1. It holds the address of the next instruction to be fetched. 2. It holds the instruction currently being decoded and executed. 3. It holds the data currently being read from or written to memory. 4. It performs logical operations, shift operations and arithmetic calculations. 5. It holds the address of the memory location currently being accessed.
查看答案詳解

解題

1. The Program Counter (PC) stores the memory address of the next instruction to be fetched. 2. The Current Instruction Register (CIR) holds the instruction currently undergoing decoding and execution. 3. The Memory Data Register (MDR) holds any data fetched from memory, or waiting to be written to memory. 4. The Arithmetic Logic Unit (ALU) performs mathematical operations and logical evaluations. 5. The Memory Address Register (MAR) stores the address of the memory location currently being read from or written to.

評分準則

Award 1 mark for each correct identification: 1. Program Counter / PC (1 mark) 2. Current Instruction Register / CIR (1 mark) 3. Memory Data Register / MDR (1 mark) 4. Arithmetic Logic Unit / ALU (1 mark) 5. Memory Address Register / MAR (1 mark)
題目 2 · short_answer
5
A software developer is preparing files for an online multiplayer game. (a) State the primary difference between lossy compression and lossless compression. [1] (b) Identify which compression type (lossy or lossless) is most suitable for: (i) The compiled game program files [1] (ii) The background ambient sound effects [1] (c) Explain why lossy compression is not suitable for the game's executable files. [2]
查看答案詳解

解題

(a) The critical distinction is that lossy compression permanently removes less critical data (resulting in quality reduction), while lossless compression reduces the file size by finding patterns without discarding any data. (b) (i) Lossless must be used for executable/program files to prevent execution failure. (ii) Lossy can be used for ambient sounds because subtle audio frequency details can be discarded without the human ear noticing. (c) Executable files must be reconstructed identically to their original state. Lossy compression permanently removes data; if code instructions or binary data are lost, the program will suffer syntax/runtime errors and become corrupt.

評分準則

Part (a): 1 mark for stating that lossy permanently deletes data while lossless retains all data/can be fully reconstructed. Part (b): 1 mark for (i) Lossless, 1 mark for (ii) Lossy. Part (c): Max 2 marks: - 1 mark: Code/executable files require 100% accurate reproduction / cannot afford to lose any data. - 1 mark: Loss of data/instructions causes code corruption, preventing the software from executing or running properly.
題目 3 · short_answer
5
An automated greenhouse system utilizes various hardware devices. (a) Explain how a capacitive touchscreen is used by the greenhouse operator to input control settings. [3] (b) Describe how an actuator is used to control the physical environment of the greenhouse. [2]
查看答案詳解

解題

(a) Capacitive screens use a layer of transparent conductive material (like indium tin oxide). When a finger (which is also conductive) touches the screen, it draws an electrical current, creating a drop in electrostatic capacity. Sensors located at the screen corners measure this change to compute the exact coordinates. (b) Actuators are physical output devices. They receive signals from the controller/microprocessor and drive mechanical actions (e.g., operating motors, solenoids, or pumps) to physically modify the system environment.

評分準則

Part (a): Max 3 marks: - 1 mark: Screen has a transparent conductive layer / electrostatic field. - 1 mark: Touching the screen transfers charge/current to the user's finger, altering the capacitance. - 1 mark: Sensors detect the location of this change and determine the exact coordinate. Part (b): Max 2 marks: - 1 mark: Actuator receives electrical control signals from the processor/system. - 1 mark: Actuator converts the electrical signals into mechanical action / physical movement (e.g., turning on a pump, opening a physical valve).
題目 4 · short_answer
5
Data storage technologies are essential in modern computing. (a) Give two reasons why solid-state storage (SSD) is preferred over magnetic storage (HDD) in a portable laptop. [2] (b) Describe how data is physically read from an optical disc, such as a DVD. [3]
查看答案詳解

解題

(a) SSDs utilize flash memory with no moving physical parts, which makes them highly resistant to drop impact. They also consume less electricity (improving battery performance), are lighter, and offer significantly faster read/write speeds than HDDs. (b) During reading, a laser light (red for DVD, blue for Blu-ray) is directed at the disc surface. The surface is stamped with flat areas (lands) and indentations (pits). When the laser strikes a land or pit, it reflects differently. A sensor reads the fluctuations in the reflected light and converts them into digital binary code.

評分準則

Part (a): Max 2 marks for any two from: - No moving parts / shock-resistant / durable. - Faster read/write/access speeds. - Lower power consumption (saves battery life). - Completely silent operation. - Lighter weight / compact physical size. Part (b): Max 3 marks: - 1 mark: A laser beam is focused onto the surface of the spinning disc. - 1 mark: The surface contains pits and lands (bumps and flats). - 1 mark: The light is reflected off the surface (pits disperse light, lands reflect light). - 1 mark: A sensor / photodetector reads the intensity of the reflection and converts these changes into binary 1s and 0s.
題目 5 · math_representation
11
This question is about data representation and number systems. (a) Convert the 8-bit unsigned binary integer 11010110 into: (i) Denary [1 mark] (ii) Hexadecimal. Show your working. [2 marks] (b) Convert the denary value -93 into an 8-bit signed binary register using two's complement representation. Show your working. [3 marks] (c) (i) Perform a logical shift right of 3 places on the 8-bit unsigned binary integer 11010100. [2 marks] (ii) State the mathematical effect of this logical shift right operation on the denary value of the original binary number. [1 mark] (d) A computer system uses hexadecimal representation for RGB colors. Convert the Red (R) and Blue (B) components of the hexadecimal color code #A43F8B into denary values. Show your working. [2 marks]
查看答案詳解

解題

Part (a)(i): \(11010110_2 = 128 + 64 + 16 + 4 + 2 = 214_{10}\). Part (a)(ii): Divide the binary sequence into two 4-bit nibbles: 1101 and 0110. \(1101_2 = 13_{10} = \text{D}_{16}\). \(0110_2 = 6_{10} = 6_{16}\). Thus, the hexadecimal representation is D6. Part (b): First, convert \(+93\) to unsigned 8-bit binary: \(93 = 64 + 16 + 8 + 4 + 1 = 01011101_2\). Next, perform the one's complement (invert all bits): 10100010. Finally, add 1 to obtain the two's complement: \(10100010 + 1 = 10100011\). Part (c)(i): Shifting 11010100 right by 3 places shifts all bits 3 positions to the right, filling the empty leftmost bits with 0s. This results in 00011010. Part (c)(ii): A logical shift right of 3 places divides the denary representation of the binary integer by \(2^3 = 8\) (with any remainder/fractional part truncated). Part (d): The 24-bit color hexadecimal format is #RRGGBB. Red component is the first pair: \(\text{A}4_{16} = 10 \times 16 + 4 = 164_{10}\). Blue component is the third pair: \(8\text{B}_{16} = 8 \times 16 + 11 = 139_{10}\).

評分準則

Part (a)(i): 1 mark for 214. Part (a)(ii): 1 mark for dividing into correct nibbles or showing correct intermediate conversion. 1 mark for correct final hexadecimal answer: D6. Part (b): 1 mark for correct conversion of positive 93 to binary (01011101). 1 mark for correct inversion of bits (10100010) or showing equivalent methodology. 1 mark for correct two's complement answer: 10100011. Part (c)(i): 1 mark for shifting the bits of the original value correctly to the right (e.g. obtaining _ _ _ 11010). 1 mark for padding the 3 empty positions on the left with 0s to get 00011010. Part (c)(ii): 1 mark for stating that it divides the number by 8 (or divides by 2 three times / integer division / fractional part lost). Reject 'division' on its own without specifying by 8 or \(2^3\). Part (d): 1 mark for Red = 164 (showing working: \(10 \times 16 + 4\)). 1 mark for Blue = 139 (showing working: \(8 \times 16 + 11\)).
題目 6 · structured
11
**Part (a)**

Describe the events that occur during the **fetch** stage of the Fetch-Decode-Execute (FDE) cycle. Your answer must refer to the roles of the specific registers and system buses involved. [6]

**Part (b)**

For each of the three descriptions below, identify the correct system bus (Address Bus, Data Bus, or Control Bus) and its direction of transmission (unidirectional or bidirectional) relative to the CPU.

1. This bus is used to transmit physical memory addresses from the CPU to the main memory (RAM).
- Name of system bus:
- Direction of transmission: [2]

2. This bus is used to transfer actual data or instructions between the CPU and other system components.
- Name of system bus:
- Direction of transmission: [2]

3. This bus carries command signals, timing signals, and status signals between the Control Unit (CU) and other hardware components.
- Name of system bus: [1]
查看答案詳解

解題

**Part (a) Walkthrough:**
During the Fetch stage, the processor retrieves an instruction from memory.
1. It begins with the **Program Counter (PC)**, which holds the address of the next instruction to be executed.
2. This address is immediately copied to the **Memory Address Register (MAR)**. This transmission is carried over the **Address Bus**.
3. The CPU then reads the instruction from the memory location specified by the MAR.
4. The instruction content is sent back to the CPU via the **Data Bus** and loaded into the **Memory Data Register (MDR)**.
5. To prepare for the next cycle, the **PC** is incremented by 1.
6. Finally, the instruction is copied from the MDR into the **Current Instruction Register (CIR)**, ready to be decoded in the next phase.

**Part (b) Walkthrough:**
1. The bus that sends memory addresses from the CPU to memory is the **Address Bus**. Because the CPU only sends addresses to memory (and never receives them from memory), it is **unidirectional**.
2. The bus that transports the actual data values and instructions to and from the CPU is the **Data Bus**. Because data must flow both into the CPU (reads) and out of the CPU (writes), this bus is **bidirectional**.
3. The bus that transmits command/control pulses (like read/write lines or clock interrupts) is the **Control Bus**. (This bus is bidirectional, though only the name is asked here for 1 mark).

評分準則

**Part (a)** [Max 6 marks]:
- 1 mark for stating the Program Counter (PC) holds/contains the address of the next instruction.
- 1 mark for stating the address is copied from the PC to the Memory Address Register (MAR).
- 1 mark for stating this address is sent/carried via the Address Bus.
- 1 mark for stating the instruction at that memory address is fetched and sent to the Memory Data Register (MDR).
- 1 mark for stating the instruction is carried via the Data Bus.
- 1 mark for stating the Program Counter (PC) is incremented (by 1).
- 1 mark for stating the instruction is copied from the MDR to the Current Instruction Register (CIR).

**Part (b)** [Max 5 marks]:
1. Address Bus [1 mark] + Unidirectional [1 mark]
2. Data Bus [1 mark] + Bidirectional [1 mark]
3. Control Bus [1 mark]

*Acceptable alternative phrasing:*
- For incrementing: "PC increases by 1", "PC is updated to point to the next instruction".
- For direction: Accept capitalization variants (unidirectional, Unidirectional).
題目 7 · descriptive
10
A software developer is writing a new computer application. They can choose to use a high-level programming language or a low-level programming language. (a) Explain two benefits of writing a program in a high-level language compared to a low-level language. [2] (b) The programmer decides to use an Integrated Development Environment (IDE) to write and test the code. Describe three features of an IDE that can help the programmer find and correct errors in their code. [6] (c) Once the program is complete, it needs to be translated. State two differences between a compiler and an interpreter. [2]
查看答案詳解

解題

Part (a): Benefits of a high-level language include: 1. It is easier to read, write, and understand as it uses English-like statements. 2. It is portable / machine-independent, meaning it can run on different hardware platforms with appropriate translation. 3. It is easier to debug and maintain. Part (b): IDE features: 1. Error diagnostics / Dynamic syntax check: Highlights syntax errors in real-time as the programmer types, or provides error messages with line numbers to easily locate mistakes. 2. Debugger (Breakpoints / Single-stepping): Allows the programmer to pause execution at specific lines (breakpoints) or execute code line-by-line (single-stepping) to inspect variables and locate logical errors. 3. Auto-complete / Auto-suggestion: Suggests variable names, keywords, or function signatures, reducing spelling and syntax errors. Part (c): Differences between a compiler and an interpreter: 1. A compiler translates the entire source code into an executable file all at once, whereas an interpreter translates and executes the source code line-by-line. 2. A compiler produces an independent executable file that runs without the translator, whereas an interpreter requires the translator to be present every time the program is run. 3. A compiler reports all errors at the end of compilation, whereas an interpreter stops execution immediately when an error is encountered.

評分準則

Part (a) [Max 2 marks]: Award 1 mark for each valid benefit up to 2: - English-like statements / easier to read, write, or understand - Portable / machine-independent (runs on different hardware) - Easier to debug / maintain. Part (b) [Max 6 marks]: Award 2 marks per feature (1 mark for naming/identifying the feature, 1 mark for describing how it helps find or correct errors), up to 3 features: - Error diagnostics / Syntax check: identifies syntax errors as they are typed / gives error reports. - Debugger (Breakpoints / Single stepping): allows stepping through code line-by-line / tracking variable values. - Auto-complete: suggests functions/variables to prevent spelling mistakes. - Syntax highlighting: color-codes different elements to spot structure/typing errors easily. Part (c) [Max 2 marks]: Award 1 mark for each valid difference up to 2: - Compiler translates whole program at once vs. interpreter line-by-line. - Compiler produces an executable file (.exe) vs. interpreter does not. - Compiler reports all errors at the end vs. interpreter stops immediately at first error.
題目 8 · Short Answer
4
An operating system (OS) is a core piece of system software. Describe how the operating system manages the following two functions: (i) Memory management [2 marks] and (ii) Interrupt handling [2 marks].
查看答案詳解

解題

For Memory Management: The operating system tracks memory usage and allocates RAM addresses to active applications. It enforces security boundaries to prevent processes from modifying or reading memory belonging to other programs. It also manages virtual memory, moving pages between physical RAM and secondary storage as needed. For Interrupt Handling: The OS monitors incoming signals from hardware or software requesting immediate CPU attention. It saves the CPU's current execution state (including registers) on a stack, runs the corresponding Interrupt Service Routine (ISR) to resolve the request, and then restores the saved registers to resume the original task.

評分準則

Memory Management (Max 2 marks): 1 mark for describing allocation of RAM/main memory to active programs; 1 mark for describing memory protection (preventing applications from overwriting each other's memory space); 1 mark for mentioning the management of virtual memory. Interrupt Handling (Max 2 marks): 1 mark for identifying that the OS detects signals from hardware or software; 1 mark for explaining that the OS saves the state of the current task; 1 mark for mentioning the execution of an Interrupt Service Routine (ISR) based on priority.
題目 9 · Short Answer
4
Many digital currencies use blockchain technology to record transactions securely. Explain the role of each of the following components in a blockchain network: (i) Peer-to-peer (P2P) network [2 marks] and (ii) Cryptographic hashing [2 marks].
查看答案詳解

解題

For Peer-to-peer (P2P) network: The system runs on a decentralized network where every node (computer) holds an identical, synchronized copy of the ledger. This removes the reliance on a central server, and transactions are validated through a consensus mechanism agreed upon by the nodes. For Cryptographic hashing: Each block of transactions is processed through an algorithm to generate a unique hash. Because each block includes the hash of the previous block, any alteration to historical transaction data changes its block's hash, which breaks the cryptographic chain and alerts the network to tampering.

評分準則

Peer-to-peer (P2P) network (Max 2 marks): 1 mark for explaining that the ledger is shared/synchronized across all decentralized nodes; 1 mark for stating that it removes the need for a central server/authority; 1 mark for mentioning that nodes use consensus algorithms to validate transactions. Cryptographic hashing (Max 2 marks): 1 mark for explaining that hashing produces a unique, fixed-size digital fingerprint of the block's data; 1 mark for stating that each block contains the hash of the previous block to create a secure chain; 1 mark for explaining that altering block data changes the hash, instantly making tampering apparent.

Paper 21 Algorithms, Programming and Logic

Answer all questions. Calculators must not be used.
11 題目 · 71
題目 1 · short answer
3
A software developer is designing a signup form where users enter a username. The username must be between 5 and 15 characters long, cannot be left empty, and must only contain alphabetic characters.

Identify three different validation checks that should be applied to this username input, explaining how each validation check would be used in this context.
查看答案詳解

解題

The username field has three distinct constraints that maps to three validation techniques:
- 'between 5 and 15 characters long' requires a **Length check** to verify that the number of characters is within the range [5, 15].
- 'cannot be left empty' requires a **Presence check** to verify that the user has actually entered some data.
- 'must only contain alphabetic characters' requires a **Type check** or **Character check** to verify that no numbers or symbols are entered.

評分準則

Award 1 mark for each correct validation check and explanation, up to a maximum of 3 marks:
- **Length check** (1 mark): To check that the username is between 5 and 15 characters long.
- **Presence check** (1 mark): To ensure the field is not left blank/empty.
- **Type check** or **Character check** (1 mark): To ensure the input contains only letters / alphabetic characters.

*Do not accept Format check as a substitute unless explained with precise rules for alphabetical constraints.*
題目 2 · short answer
3
Operators are fundamental components used in pseudocode algorithms.

Classify each of the following three operators as either **Arithmetic**, **Comparison (Relational)**, or **Logical**:

1. `<>`
2. `MOD`
3. `NOT`
查看答案詳解

解題

1. `<>` represents 'not equal to', which compares two values. Therefore, it is a **Comparison (Relational)** operator.
2. `MOD` calculates the remainder of an integer division. Therefore, it is an **Arithmetic** operator.
3. `NOT` performs a boolean inversion. Therefore, it is a **Logical** operator.

評分準則

Award 1 mark for each correct classification:
- 1. `<>` = Comparison or Relational (1 mark)
- 2. `MOD` = Arithmetic (1 mark)
- 3. `NOT` = Logical (1 mark)
題目 3 · short answer
3
The first stage of the Systems Development Life Cycle (SDLC) is Analysis.

State three different fact-finding (information gathering) techniques that a systems analyst could use during this stage to understand an existing system.
查看答案詳解

解題

During the Analysis stage, a systems analyst must gather detailed information about how the current system functions. The main techniques are:
- **Interviews**: Speaking directly to users and stakeholders.
- **Questionnaires / Surveys**: Distributing written questions to collect feedback from a larger group of users.
- **Observation**: Watching staff use the current system in their daily routine.
- **Document lookup**: Examining existing manuals, system documentations, or forms.

評分準則

Award 1 mark for any of the following techniques, up to a maximum of 3 marks:
- Interviewing / Interviews
- Questionnaires / Surveys
- Observation / observing workflows
- Document lookup / examining existing documentation / records

*Reject: Testing, Prototyping.*
題目 4 · short answer
3
An examination database stores student records.

State the most appropriate type of validation check to ensure:

1. A student's exam score is not less than 0 and not greater than 100.
2. A student's ID starts with the letter 'S' followed by exactly four digits.
3. Keying errors in a numeric student ID are detected using an extra calculated digit at the end.
查看答案詳解

解題

1. **Range check**: Verifies that a numeric value falls within a specified upper and lower limit (0 to 100).
2. **Format check**: Verifies that data conforms to a predetermined pattern/format (such as letter 'S' followed by 4 digits).
3. **Check digit**: An extra digit calculated from the other digits in a number, used to detect errors in manual entry or transmission.

評分準則

Award 1 mark for each correct validation type:
- 1. Range check (1 mark)
- 2. Format check / Picture check (1 mark)
- 3. Check digit (1 mark)
題目 5 · short answer
3
A program is designed to accept an input integer representing a user's age, which must be in the range 18 to 65 inclusive.

Identify the type of test data (Normal, Boundary, or Erroneous) represented by each of the following test inputs:

1. `17`
2. `18`
3. `40`
查看答案詳解

解題

1. `17` is outside the allowed range of 18 to 65. It should be rejected by the system, so it represents **Erroneous** (or abnormal) test data.
2. `18` is on the edge of the accepted range (the lower limit). It represents **Boundary** (or extreme) test data.
3. `40` is inside the accepted range. It represents **Normal** test data.

評分準則

Award 1 mark for each correct identification:
- 1. Erroneous / Abnormal / Invalid (1 mark)
- 2. Boundary / Extreme (1 mark)
- 3. Normal / Valid (1 mark)
題目 6 · practical
8
An algorithm is written in pseudocode to process a list of integers stored in an array.

```pseudocode
DECLARE Values : ARRAY[1:6] OF INTEGER
DECLARE Count, Temp, Result : INTEGER
Values[1] <-- 12
Values[2] <-- 7
Values[3] <-- 15
Values[4] <-- 4
Values[5] <-- 9
Values[6] <-- 14
Result <-- 0

FOR Count <-- 1 TO 6
Temp <-- Values[Count] MOD 3
IF Temp = 0 THEN
Result <-- Result + Values[Count]
ELSE
Result <-- Result - Temp
ENDIF
NEXT Count
OUTPUT Result
```

Complete the trace table below for this algorithm.

| Count | Values[Count] | Temp | Result | OUTPUT |
| :---: | :-----------: | :--: | :----: | :----: |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
查看答案詳解

解題

The trace proceeds as follows:
- Initially, `Result` is initialized to `0`.
- `Count = 1`: `Values[1]` is `12`. `Temp` is `12 MOD 3 = 0`. Since `Temp = 0`, `Result` becomes `0 + 12 = 12`.
- `Count = 2`: `Values[2]` is `7`. `Temp` is `7 MOD 3 = 1`. Since `Temp <> 0`, `Result` becomes `12 - 1 = 11`.
- `Count = 3`: `Values[3]` is `15`. `Temp` is `15 MOD 3 = 0`. Since `Temp = 0`, `Result` becomes `11 + 15 = 26`.
- `Count = 4`: `Values[4]` is `4`. `Temp` is `4 MOD 3 = 1`. Since `Temp <> 0`, `Result` becomes `26 - 1 = 25`.
- `Count = 5`: `Values[5]` is `9`. `Temp` is `9 MOD 3 = 0`. Since `Temp = 0`, `Result` becomes `25 + 9 = 34`.
- `Count = 6`: `Values[6]` is `14`. `Temp` is `14 MOD 3 = 2`. Since `Temp <> 0`, `Result` becomes `34 - 2 = 32`.
- After the loop, `OUTPUT Result` prints `32`.

評分準則

- 1 mark: Initializing Result to 0 on the first row with other columns blank.
- 1 mark: Correct values for `Count` and `Values[Count]` columns (rows 1 to 6).
- 1 mark: Correct values for `Temp` (0, 1, 0, 1, 0, 2).
- 3 marks: Correct updates to `Result` throughout the iterations (12 & 11; 26 & 25; 34 & 32).
- 1 mark: Final output of 32 on its own line.
- 1 mark: Clean trace table format with no extra or incorrect values.
題目 7 · practical
8
The following pseudocode algorithm is intended to find the average and the highest value of a series of positive numbers entered by a user. The input is terminated when the user enters -1.

However, the algorithm contains four errors.

```pseudocode
1: DECLARE Number, Sum, Count, Highest, Average : REAL
2: Sum <-- 0
3: Count <-- 0
4: Highest <-- 0
5: REPEAT
6: OUTPUT "Enter a positive number or -1 to stop:"
7: INPUT Number
8: IF Number > -1 THEN
9: Sum <-- Sum + Number
10: Count <-- Count - 1
11: IF Number < Highest THEN
12: Highest <-- Number
13: ENDIF
14: ENDIF
15: UNTIL Number <> -1
16: IF Count > 0 THEN
17: Average <-- Sum * Count
18: OUTPUT "Average: ", Average
19: OUTPUT "Highest: ", Highest
20: ELSE
21: OUTPUT "No valid numbers entered."
22: ENDIF
```

Identify the line numbers of the four errors and state the correct pseudocode statement for each.
查看答案詳解

解題

The errors are:
1. On **Line 10**, `Count <-- Count - 1` decrements the count instead of incrementing it. To count how many numbers have been entered, it must be `Count <-- Count + 1`.
2. On **Line 11**, the comparison is checking if `Number < Highest`, which would keep `Highest` at its initial low value (0) instead of updating it to the maximum value. It should be `IF Number > Highest THEN`.
3. On **Line 15**, `UNTIL Number <> -1` would terminate the loop on the very first input that is NOT -1. It should loop until -1 is entered: `UNTIL Number = -1`.
4. On **Line 17**, the calculation of the average multiplies the `Sum` by `Count` instead of dividing. It should be `Average <-- Sum / Count`.

評分準則

- 2 marks: Identifying Line 10 error and providing the correction `Count <-- Count + 1` (1 mark for line/error identification, 1 mark for correction).
- 2 marks: Identifying Line 11 error and providing the correction `IF Number > Highest THEN` (1 mark for line/error identification, 1 mark for correction).
- 2 marks: Identifying Line 15 error and providing the correction `UNTIL Number = -1` (1 mark for line/error identification, 1 mark for correction).
- 2 marks: Identifying Line 17 error and providing the correction `Average <-- Sum / Count` (1 mark for line/error identification, 1 mark for correction).
題目 8 · practical
8
The following pseudocode algorithm processes an array named `Data` and saves a filtered list of unique elements to another array named `OutData`.

```pseudocode
DECLARE Data : ARRAY[1:5] OF INTEGER
DECLARE OutData : ARRAY[1:5] OF INTEGER
DECLARE I, J, K : INTEGER

Data[1] <-- 4
Data[2] <-- 4
Data[3] <-- 7
Data[4] <-- 2
Data[5] <-- 2

J <-- 1
OutData[1] <-- Data[1]

FOR I <-- 2 TO 5
IF Data[I] <> Data[I-1] THEN
J <-- J + 1
OutData[J] <-- Data[I]
ENDIF
NEXT I

FOR K <-- 1 TO J
OUTPUT OutData[K]
NEXT K
```

Complete the trace table below for this algorithm.

| I | J | OutData[1] | OutData[2] | OutData[3] | K | OUTPUT |
| :-: | :-: | :--------: | :--------: | :--------: | :-: | :----: |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
查看答案詳解

解題

The trace proceeds as follows:
- Initially, J is set to 1 and `OutData[1]` is assigned `Data[1]` (which is 4).
- `I = 2`: `Data[2] <> Data[1]` is `4 <> 4` (False). No changes inside the loop.
- `I = 3`: `Data[3] <> Data[2]` is `7 <> 4` (True). `J` is incremented to 2, and `OutData[2]` is assigned `Data[3]` (which is 7).
- `I = 4`: `Data[4] <> Data[3]` is `2 <> 7` (True). `J` is incremented to 3, and `OutData[3]` is assigned `Data[4]` (which is 2).
- `I = 5`: `Data[5] <> Data[4]` is `2 <> 2` (False). No changes inside the loop.
- Loop terminates with `J = 3`.
- Output loop starts from `K = 1` to `3`:
- `K = 1`: outputs `OutData[1]` which is `4`.
- `K = 2`: outputs `OutData[2]` which is `7`.
- `K = 3`: outputs `OutData[3]` which is `2`.

評分準則

- 1 mark: Initializing J = 1 and OutData[1] = 4 correctly on the first row.
- 1 mark: Correctly setting I = 2 and keeping J/OutData unchanged on row 2.
- 1 mark: Correctly setting I = 3, updating J = 2 and OutData[2] = 7 on row 3.
- 1 mark: Correctly setting I = 4, updating J = 3 and OutData[3] = 2 on row 4.
- 1 mark: Correctly setting I = 5 and keeping J/OutData unchanged on row 5.
- 3 marks: Tracing the output loop correctly for K = 1, 2, 3 and showing the correct output stream (4, 7, 2) in the OUTPUT column (1 mark per step of the output loop).
題目 9 · structured
7
A chemical process monitoring system uses three inputs:
- **Temperature (A)**: 1 if high, 0 if normal
- **Pressure (B)**: 1 if high, 0 if normal
- **Valve Status (C)**: 1 if open, 0 if closed

An alarm system output (**X**) is activated (1) if:
- Temperature is high AND Pressure is normal
- **OR**
- Valve status is closed AND Pressure is high

**(a)** Write a Boolean logic expression for the alarm output **X** using the inputs A, B, and C. [3]

**(b)** Complete the truth table below for the logic expression you created. [4]

| A | B | C | X |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 0 | 1 | |
| 0 | 1 | 0 | |
| 0 | 1 | 1 | |
| 1 | 0 | 0 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 | |
| 1 | 1 | 1 | |
查看答案詳解

解題

### Part (a) Formulation:
1. "Temperature is high AND Pressure is normal" translates to: \(A \text{ AND NOT } B\).
2. "Valve status is closed AND Pressure is high" translates to: \(\text{NOT } C \text{ AND } B\).
3. These two terms are combined with an OR operator: \(X = (A \text{ AND NOT } B) \text{ OR } (\text{NOT } C \text{ AND } B)\).

### Part (b) Evaluation:
- **Row 1 (0,0,0)**: \((0 \text{ AND } 1) \text{ OR } (1 \text{ AND } 0) = 0 \text{ OR } 0 = 0\)
- **Row 2 (0,0,1)**: \((0 \text{ AND } 1) \text{ OR } (0 \text{ AND } 0) = 0 \text{ OR } 0 = 0\)
- **Row 3 (0,1,0)**: \((0 \text{ AND } 0) \text{ OR } (1 \text{ AND } 1) = 0 \text{ OR } 1 = 1\)
- **Row 4 (0,1,1)**: \((0 \text{ AND } 0) \text{ OR } (0 \text{ AND } 1) = 0 \text{ OR } 0 = 0\)
- **Row 5 (1,0,0)**: \((1 \text{ AND } 1) \text{ OR } (1 \text{ AND } 0) = 1 \text{ OR } 0 = 1\)
- **Row 6 (1,0,1)**: \((1 \text{ AND } 1) \text{ OR } (0 \text{ AND } 0) = 1 \text{ OR } 0 = 1\)
- **Row 7 (1,1,0)**: \((1 \text{ AND } 0) \text{ OR } (1 \text{ AND } 1) = 0 \text{ OR } 1 = 1\)
- **Row 8 (1,1,1)**: \((1 \text{ AND } 0) \text{ OR } (0 \text{ AND } 1) = 0 \text{ OR } 0 = 0\)

評分準則

### Part (a) [Max 3 marks]:
- **1 mark**: For first term correctly represented: `A AND NOT B` (accept equivalents such as `A . \bar{B}` if boolean algebra is used).
- **1 mark**: For second term correctly represented: `NOT C AND B` or `B AND NOT C`.
- **1 mark**: For linking both correct terms together with `OR`.

### Part (b) [Max 4 marks]:
- **4 marks**: All 8 outputs correct (`0, 0, 1, 0, 1, 1, 1, 0`).
- **3 marks**: 6 or 7 outputs correct.
- **2 marks**: 4 or 5 outputs correct.
- **1 mark**: 2 or 3 outputs correct.
- **0 marks**: 0 or 1 output correct.
題目 10 · structured
10
A forestry conservation group uses a database table named TREES to store information about trees in a nature reserve. A sample of the database table is shown below:

| TreeID | Species | Age | Height | Protected |
| :--- | :--- | :--- | :--- | :--- |
| TR101 | Oak | 120 | 24.5 | TRUE |
| TR102 | Pine | 45 | 18.2 | FALSE |
| TR103 | Oak | 85 | 19.8 | TRUE |
| TR104 | Birch | 30 | 12.4 | FALSE |
| TR105 | Pine | 110 | 28.1 | TRUE |
| TR106 | Willow | 15 | 8.5 | FALSE |

(a) Identify a suitable field to be used as a primary key and justify your choice. [2]

(b) Write an SQL query to display the Species and Height of all trees that are older than 80 years and are protected. [4]

(c) State the output that would be produced by executing the following SQL query. [4]

SELECT Species, Age
FROM TREES
WHERE Protected = FALSE AND Height > 10.0
ORDER BY Age DESC;
查看答案詳解

解題

(a)
- Primary Key: TreeID
- Justification: Every tree requires a unique identifier to ensure that individual records can be retrieved accurately without confusion. TreeID is unique for each record.

(b)
```sql
SELECT Species, Height
FROM TREES
WHERE Age > 80 AND Protected = TRUE;
```

(c)
The query filters for trees where Protected is FALSE and Height is greater than 10.0 (TR102 and TR104 match; TR106 is excluded because its height is 8.5). It displays only the Species and Age fields, ordered from highest to lowest age.

Expected Output Table:

| Species | Age |
| :--- | :--- |
| Pine | 45 |
| Birch | 30 |

評分準則

Part (a) [2 Marks]
- 1 mark: Identifies TreeID as the primary key.
- 1 mark: Valid justification (e.g., contains unique values for each record / prevents duplication).

Part (b) [4 Marks]
- 1 mark: SELECT Species, Height
- 1 mark: FROM TREES
- 1 mark: WHERE Age > 80
- 1 mark: AND Protected = TRUE (also accept Protected = Yes or Protected)

Part (c) [4 Marks]
- 1 mark: Correct columns present (Species and Age only, in correct order).
- 1 mark: Correct rows identified (Pine and Birch only, Willow/Oaks excluded).
- 1 mark: Correct values for fields (Pine/45, Birch/30).
- 1 mark: Correct descending order based on Age (Pine record first, Birch record second).
題目 11 · scenario
15
A transport company wants to monitor the fuel efficiency of its fleet of 5 delivery vehicles. Write an algorithm, using pseudocode, that meets the following requirements:

1. Use a 1-dimensional array called `VehicleID` which contains the pre-stored registration numbers: "VEH01", "VEH02", "VEH03", "VEH04", "VEH05". (You do not need to write the code to populate this array, but you must assume it is fully initialized).

2. Prompt and input the distance traveled (in km) and the fuel consumed (in liters) for each of the 5 vehicles.

3. Validate the input data:
* Distance must be greater than 0 and less than or equal to 2500 km.
* Fuel consumed must be greater than 0 and less than or equal to 400 liters.
* The program must keep prompting until valid values are entered.

4. Calculate and store the fuel efficiency (km per liter) for each vehicle in a 1-dimensional array called `Efficiency`.

5. Output the registration number and the calculated fuel efficiency for each vehicle.

6. Determine and output:
* The registration number of the vehicle with the best (highest) fuel efficiency.
* The registration number of the vehicle with the worst (lowest) fuel efficiency.
* The average fuel efficiency of the entire fleet.

Declare all variables you use.
查看答案詳解

解題

The solution requires declaring all variables first, including arrays. A `FOR` loop runs 5 times to process each vehicle. Inside this loop, nested post-assertion validation loops (`REPEAT...UNTIL`) ensure only valid data is entered for distance and fuel. The fuel efficiency is computed as `Distance / Fuel` and saved in the `Efficiency` array. The running sum `TotalEfficiency` is updated. After the main input loop, a second loop determines the maximum and minimum efficiency indices. Finally, the program computes the average and outputs all requested statistics with clear messages.

評分準則

Marking Scheme (Max 15 marks):

Variable Declaration (2 marks):
* 1 mark: Declaring 1D array `Efficiency` of size 5 with type `REAL`.
* 1 mark: Declaring all other variables (`Distance`, `Fuel`, loop counters, accumulator, min/max tracking) with appropriate data types.

Input and Validation Loop (4 marks):
* 1 mark: Use of a `FOR` loop (or equivalent) running exactly 5 times.
* 1 mark: Prompt and input for both `Distance` and `Fuel`.
* 1 mark: Correct post-assertion validation loop (`REPEAT...UNTIL` or `WHILE...DO`) for Distance with boundary conditions (`> 0` and `<= 2500`).
* 1 mark: Correct post-assertion validation loop for Fuel with boundary conditions (`> 0` and `<= 400`).

Efficiency Calculation and Array Storage (3 marks):
* 1 mark: Correct calculation of efficiency (`Distance / Fuel`).
* 1 mark: Storing calculated efficiency in the corresponding array index `Efficiency[i]`.
* 1 mark: Accumulating the total efficiency (`TotalEfficiency <- TotalEfficiency + Efficiency[i]`) for average calculation.

Min/Max and Fleet Average Logic (4 marks):
* 1 mark: Initializing best/worst variables with the first element of the array before comparison.
* 1 mark: Correct loop logic to search the arrays from index 2 to 5.
* 1 mark: Correct comparison conditions to find both index of maximum and index of minimum efficiency.
* 1 mark: Correct calculation of fleet average efficiency (`TotalEfficiency / 5`).

Outputs (2 marks):
* 1 mark: Outputting the vehicle ID and efficiency for each vehicle inside or outside the main loop.
* 1 mark: Outputting the overall best vehicle ID, worst vehicle ID, and fleet average with descriptive labels.

想知道自己有幾分把握?

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

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

免費開始練習