Cambridge IGCSE · thinka 原创模拟试题

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

Thinka Jun 2024 (V3) Cambridge IGCSE-Style Mock — Computer Science (0478)

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

卷一 Computer Systems

Answer all questions. Calculators are not allowed. Show all your working for conversions and calculations.
24 题目 · 66
题目 1 · Short recall
1.5
Explain why a designer of web pages would prefer to use hexadecimal representation instead of binary when defining HTML color codes.
查看答案详解

解题

Hexadecimal provides a more compact representation of values compared to binary (6 hex digits vs 24 binary bits for color codes). This significantly reduces the complexity for web developers, allowing them to read, write, and debug code with greater speed and fewer typos.

评分标准

1 mark for identifying that hexadecimal is shorter, more compact, or easier to read than binary. 0.5 mark for linking this benefit to a reduction in user input errors or increased developer efficiency.
题目 2 · Short recall
1.5
Identify the main limitation of Solid State Drives (SSDs) related to write cycles, and state how this affects their overall lifespan.
查看答案详解

解题

Unlike magnetic hard drives, SSD cells suffer physical degradation with every write/erase cycle. Therefore, they have a finite endurance, meaning high-frequency writing activities will lead to block failure and limit the functional longevity of the drive.

评分标准

1 mark for identifying the limitation of finite write/erase cycles (degradation of NAND cells). 0.5 mark for explaining that this limits longevity or leads to eventual drive failure.
题目 3 · Short recall
1.5
State the primary function of an actuator in an automated physical system and provide one real-world example of its use.
查看答案详解

解题

Actuators are output devices that take electrical signals processed by a computer system and translate them into mechanical motion. A typical application is the opening of a motorized valve in a chemical processing plant or moving a robotic joint.

评分标准

1 mark for describing the conversion of electrical signals into mechanical action or physical movement. 0.5 mark for providing a valid, clear real-world example.
题目 4 · Short recall
1.5
Describe how data is transmitted in a simplex mode, and state one typical hardware device that utilizes this transmission type.
查看答案详解

解题

Simplex transmission allows data to travel in a single, predetermined direction with no feedback path. A computer keyboard is a classic example, as it only sends inputs to the processor and cannot receive data back from it.

评分标准

1 mark for describing simplex as strictly unidirectional (one direction only). 0.5 mark for identifying a valid hardware device (e.g., keyboard, speaker, simple sensor).
题目 5 · Short recall
1.5
State what is meant by 'phishing' and explain one common indicator that can help a user identify a phishing email.
查看答案详解

解题

Phishing involves sending fraudulent emails disguised as trustworthy entities to trick users into revealing credentials or financial details. A key indicator is a sender email address that does not match the official domain of the organization it claims to represent.

评分标准

1 mark for defining phishing as fraudulent communication to steal sensitive data/credentials. 0.5 mark for identifying a valid indicator (e.g., generic greeting, urgent/threatening language, spelling errors, mismatched sender domain).
题目 6 · Short recall
1.5
State the specific purpose of the Program Counter (PC) register within the Von Neumann central processing unit model.
查看答案详解

解题

During the instruction cycle, the Program Counter keeps track of the sequence of execution. It holds the RAM address of the instruction about to be processed, and it increments automatically once the current fetch step is complete.

评分标准

1 mark for stating it holds the memory address of the next instruction. 0.5 mark for mentioning that it automatically increments during the fetch stage.
题目 7 · Short recall
1.5
Explain why lossy compression is acceptable for streaming audio files over the internet, despite permanently discarding some data.
查看答案详解

解题

Lossy compression algorithms target and remove redundant audio frequencies that most humans cannot easily hear (psychoacoustics). By doing so, the file size is reduced significantly, allowing smooth transmission over typical internet bandwidths without a noticeable drop in perceived quality.

评分标准

1 mark for explaining that it reduces file size/bandwidth requirement for smoother transmission. 0.5 mark for noting that discarded data is typically imperceptible to the human ear.
题目 8 · Short recall
1.5
Describe how a checksum is calculated and compared to detect errors in transmitted data blocks.
查看答案详解

解题

Before transmission, the sending system runs an algorithm on the block of data to produce a numerical checksum value, which is sent along with the data. Upon receipt, the destination system recalculates the checksum using the same algorithm. If the calculated value matches the received value, the data is assumed correct; a mismatch indicates a corruption error.

评分标准

1 mark for explaining the recalculation by the receiver and the subsequent comparison of the values. 0.5 mark for stating that a difference between the sent and calculated checksums indicates a transmission error.
题目 9 · Short recall
1.5
State three reasons why hexadecimal numbers are frequently used by computer programmers instead of binary.
查看答案详解

解题

Hexadecimal numbers provide a much shorter representation of binary values (one hex digit represents four binary bits), making them significantly easier for human programmers to read, write, and debug. This compactness saves screen space and dramatically reduces human errors during copying or transcription.

评分标准

Award 0.5 marks for each valid reason up to a maximum of 1.5 marks:
- Easier/quicker for humans to read, write, or debug.
- Shorter/more compact representation of binary / takes up less screen space.
- Less likely to make errors when typing, copying, or transcribing.
题目 10 · Short recall
1.5
Explain the primary purpose of the Program Counter (PC) register in the CPU during the fetch-decode-execute cycle.
查看答案详解

解题

The main role of the Program Counter (PC) is to hold the address of the next instruction that needs to be retrieved from RAM. During the fetch stage, this address is copied to the Memory Address Register (MAR), and the PC is then incremented by 1 so that it is ready for the next cycle.

评分标准

1.5 marks total:
- 1 mark: Stating that the PC stores/holds the memory address of the next instruction to be fetched/executed.
- 0.5 marks: Stating that it is incremented/updated (by 1) after the current instruction address is passed to the MAR.
题目 11 · Short recall
1.5
State the primary difference between a resistive touch screen and a capacitive touch screen in terms of how they detect a user's touch.
查看答案详解

解题

Resistive touch screens rely on mechanical pressure applied by a finger or stylus to push two flexible, conductive sheets together, completing a circuit. Capacitive touch screens utilize a conductive layer that senses changes in electrostatic capacity when touched by a conductive object, such as a bare human finger.

评分标准

1.5 marks total:
- 1 mark: Explaining that resistive screens rely on physical pressure / pushing two conductive layers together.
- 0.5 marks: Explaining that capacitive screens rely on electrical charge / capacitance changes / electrostatic fields from a conductive finger (stylus cannot be used unless conductive).
题目 12 · Short recall
1.5
Give three examples of events or conditions that can generate a hardware interrupt in a computer system.
查看答案详解

解题

Hardware interrupts are signals generated by physical components outside the CPU. Typical examples include user inputs (like a key press or mouse click), device status changes (such as a printer warning of no paper), or critical system alerts (like a low battery power warning).

评分标准

Award 0.5 marks for each valid hardware interrupt up to a maximum of 1.5 marks:
- User input device signal (e.g., key press, mouse click/move).
- Peripheral status change (e.g., printer out of paper, printer paper jam).
- System alert (e.g., low battery warning, hardware overheat, power loss).
- Data transmission complete signal (e.g., read/write operation complete).
题目 13 · Conversion calculation
2
Convert the denary number 163 into an 8-bit binary number. Show all your working.
查看答案详解

解题

To convert the denary number 163 to binary:
Subtract the largest possible powers of 2:
- \(163 - 128 = 35\) (with 1 in the 128 column)
- \(35 - 32 = 3\) (with 0 in the 64 column, 1 in the 32 column)
- Since 16 and 8 are larger than 3, we put 0 in the 16 and 8 columns.
- Since 4 is larger than 3, we put 0 in the 4 column.
- \(3 - 2 = 1\) (with 1 in the 2 column)
- \(1 - 1 = 0\) (with 1 in the 1 column)

Combining the bits: 10100011.

评分标准

- 1 mark for showing correct working (e.g., successive division by 2 or subtraction of powers of 2)
- 1 mark for the correct 8-bit binary representation: 10100011
题目 14 · Conversion calculation
2
Convert the hexadecimal number B7 into a denary number. Show all your working.
查看答案详解

解题

To convert B7 to denary:
1. Find the value of B in denary, which is 11.
2. Multiply this value by the weight of the second column (16):
\(11 \times 16 = 176\)
3. Add the value of the first column (7):
\(176 + 7 = 183\).

评分标准

- 1 mark for showing correct conversion of B to 11 and multiplying by 16
- 1 mark for the correct denary value: 183
题目 15 · Conversion calculation
2
Calculate the 8-bit two's complement representation for the negative denary number -58. Show all your working.
查看答案详解

解题

Method 1: Using the inversion and add-1 method
1. Convert positive 58 to binary: \(00111010\)
2. Invert all the bits: \(11000101\)
3. Add 1 to the result: \(11000110\)

Method 2: Using binary column weights
Columns: -128, 64, 32, 16, 8, 4, 2, 1
\(-128 + 64 + 4 + 2 = -58\)
This gives the binary value: 11000110.

评分标准

- 1 mark for correct working showing binary representation of +58 (00111010) or showing inversion of bits (11000101) or showing column weight calculations
- 1 mark for the correct final binary answer: 11000110
题目 16 · Conversion calculation
2
Convert the 12-bit binary number 110001011110 into hexadecimal. Show all your working.
查看答案详解

解题

To convert the 12-bit binary number into hexadecimal:
1. Split the binary number into groups of 4 bits (nibbles) from right to left:
\(1100\) | \(0101\) | \(1110\)
2. Convert each group to its hexadecimal equivalent:
- \(1100\) in denary is 12, which represents the hex character C
- \(0101\) in denary is 5, which represents the hex character 5
- \(1110\) in denary is 14, which represents the hex character E
3. Combine the characters to get the hexadecimal value: C5E.

评分标准

- 1 mark for correctly splitting the binary number into 4-bit groups and converting at least one group correctly
- 1 mark for the correct hexadecimal string: C5E
题目 17 · Conversion calculation
2
A network device is assigned an IP address. One of the bytes in hexadecimal representation is 41. Convert this value 41 into an 8-bit binary number. Show all your working.
查看答案详解

解题

To convert hexadecimal 41 to binary:
Method 1: Convert each hex digit to its 4-bit binary equivalent:
- \(4\) in binary is \(0100\)
- \(1\) in binary is \(0001\)
Combine them: \(01000001\)

Method 2: Convert to denary first, then to binary:
- \((4 \times 16) + 1 = 65\) in denary
- Convert 65 to binary: \(64 + 1\), which is \(01000001\).

评分标准

- 1 mark for showing correct working (either splitting hex digits and converting individually, or converting to denary value 65)
- 1 mark for the correct 8-bit binary representation: 01000001
题目 18 · Complete table / diagrams
5
A network administrator is configuring a Local Area Network (LAN) for an office. Complete the table by matching the correct network device next to each description. Use the following devices: Router, Switch, Hub, Network Interface Card (NIC), Wireless Access Point (WAP). Description 1: Directs data packets between different networks using IP addresses. Description 2: Connects devices in a wired network and forwards data packets only to the intended destination MAC address. Description 3: Broadcasts incoming data packets to all of its ports, causing high network traffic. Description 4: A hardware component inside a device that allows it to connect to a network. Description 5: Allows wireless-enabled devices to connect to a wired network using radio waves.
查看答案详解

解题

1: Router (routes packets between different networks using IP addresses). 2: Switch (sends packets directly to specific MAC addresses to reduce collisions). 3: Hub (sends data packets to every connected port). 4: Network Interface Card (NIC) (physical controller allowing a computer to access a network). 5: Wireless Access Point (WAP) (allows Wi-Fi devices to connect to the physical wired LAN).

评分标准

Award 1 mark for each correctly identified network device. [Max 5 marks]
题目 19 · Complete table / diagrams
5
Complete the statements about language translators by matching each description to the correct translator: Compiler, Interpreter, or Assembler. Statement 1: Translates assembly language programs directly into machine code. Statement 2: Translates the entire high-level language source program at once to produce an independent executable file. Statement 3: Translates high-level language source code line-by-line, executing each instruction immediately. Statement 4: Does not output an executable file, meaning the translator is required every time the program is executed. Statement 5: Usually halts the program's execution and reports an error as soon as it encounters the first issue.
查看答案详解

解题

1: Assembler (specifically translates assembly language). 2: Compiler (produces a standalone .exe file). 3: Interpreter (translates line-by-line). 4: Interpreter (requires the interpreter runtime on the machine during run-time). 5: Interpreter (stops immediately upon discovering a syntax error).

评分标准

Award 1 mark for each correctly matched translator type. [Max 5 marks]
题目 20 · Complete table / diagrams
5
A company is training its staff on web safety. Complete the table matching each cyber security threat description to its correct name. Threat 1: Malicious code installed on a computer or DNS server that redirects a user's browser to a fake website, even if the correct URL is typed. Threat 2: A type of malware that locks down a computer system or encrypts files, demanding a financial payment to restore access. Threat 3: A social engineering technique where attackers send deceptive emails pretending to be a trustworthy organization to steal login details. Threat 4: Malicious software that secretly tracks and records user inputs, such as keystrokes, and transmits this data to a third party. Threat 5: A destructive program disguised as a harmless, genuine application to trick the user into installing it.
查看答案详解

解题

1: Pharming (attacks DNS/browser redirects). 2: Ransomware (encrypts files for payment). 3: Phishing (deceptive emails for credential harvesting). 4: Spyware (keyloggers tracking usage secretly). 5: Trojan horse (disguised malware).

评分标准

Award 1 mark for each correctly matched threat name. Accept 'Trojan' for Trojan horse. [Max 5 marks]
题目 21 · Complete table / diagrams
5
Computers rely on many different peripheral devices. Complete the list by matching each functional description to the correct input or output device. Description 1: An output device that converts electrical control signals into physical movement to operate components like motors, pumps, or valves. Description 2: An input device designed to read a printed two-dimensional grid of black and white squares, often directing a smartphone to a web link. Description 3: An input device that scans physical photographs or printed documents and converts them into digital bitmap images. Description 4: An output device that builds physical solid objects layer-by-layer using thermoplastic materials from digital design files. Description 5: An input device that uses a laser or light source to read the sequence of parallel lines of varying thicknesses on retail products.
查看答案详解

解题

1: Actuator (converts signals to mechanical movement). 2: QR code reader (reads 2D matrices/squares). 3: 2D scanner (creates digital bitmaps from paper pages). 4: 3D printer (creates layered real objects). 5: Barcode reader (scans 1D parallel lines).

评分标准

Award 1 mark for each correctly identified input or output device. Accept 'Scanner' for 2D scanner, 'QR scanner' for QR code reader, 'Barcode scanner' for Barcode reader. [Max 5 marks]
题目 22 · Descriptive processes
6
A customer is purchasing goods from an e-commerce website. The website uses HTTPS to secure transactions. Describe the process of how a secure SSL/TLS connection is established between the user's web browser and the web server before the web page is retrieved.
查看答案详解

解题

First, the browser requests the web server to identify itself and establish a secure session. The web server responds by sending a copy of its SSL/TLS certificate, which contains the server's public key. The browser validates this certificate against a list of trusted Certification Authorities to ensure authenticity. Once verified, the browser generates a symmetric session key, encrypts it using the server's public key, and sends the encrypted session key to the server. The web server uses its private key to decrypt the session key. Finally, the server sends back an encrypted acknowledgement using the session key, and a secure symmetric session is established for subsequent data transmission.

评分标准

One mark per valid point up to a maximum of 6 marks: 1. Browser sends request to server to establish secure session. 2. Server sends its SSL/TLS certificate (containing public key). 3. Browser checks certificate validity with a trusted CA. 4. Browser generates symmetric session key. 5. Browser encrypts session key using server's public key and sends it. 6. Server decrypts session key using its private key. 7. Server sends encrypted acknowledgement. 8. Subsequent data is encrypted symmetrically using the session key.
题目 23 · Descriptive processes
6
A CPU is executing instructions using the von Neumann model. Describe the fetch stage of the fetch-decode-execute cycle, making reference to the roles of the Program Counter (PC), Memory Address Register (MAR), Memory Data Register (MDR), and Current Instruction Register (CIR).
查看答案详解

解题

The fetch stage begins with the Program Counter (PC), which holds the address of the next instruction to be fetched. This address is copied from the PC to the Memory Address Register (MAR) via the address bus. Simultaneously, the PC is incremented by one to point to the next instruction in sequence. The CPU then sends a read signal along the control bus to main memory (RAM). The instruction stored at the address held in the MAR is located and transferred to the Memory Data Register (MDR) via the data bus. Finally, the instruction is copied from the MDR to the Current Instruction Register (CIR), ready for the decode stage.

评分标准

One mark per valid point up to a maximum of 6 marks: 1. PC holds address of next instruction. 2. Address is copied from PC to MAR (via address bus). 3. PC is incremented (by one). 4. Instruction at address in MAR is located in RAM. 5. Instruction is transferred from RAM to MDR (via data bus). 6. Instruction is copied from MDR to CIR. 7. Correct mention of buses (address, data, or control) linked to the transfer of address/data.
题目 24 · Descriptive processes
6
A town has installed an automated street lighting system. The system uses light sensors to turn the streetlights on when it becomes dark, and off when it becomes light. Describe the continuous process of how the automated system uses the sensor, microprocessor, and actuators to control the streetlights.
查看答案详解

解题

The automated system works in a continuous loop. First, the light sensor continuously measures the ambient light levels of the surroundings. This physical measurement is sent as an analog signal to the microprocessor system. Because microprocessors cannot read analog signals, an Analog-to-Digital Converter (ADC) converts the signal into digital data. The microprocessor compares this digital data against a pre-set threshold value. If the light reading is below the threshold (indicating it is dark), the microprocessor sends a signal to the actuator to switch the streetlights on. If the reading is above or equal to the threshold, it sends a signal to turn the lights off (or keep them off). The system then waits for a short duration before repeating the entire process.

评分标准

One mark per valid point up to a maximum of 6 marks: 1. Sensor continuously measures ambient light levels. 2. Sensor sends analog data/signals to the system. 3. ADC converts analog signals to digital data. 4. Microprocessor compares digital data to a pre-stored/pre-set threshold value. 5. If light level < threshold, microprocessor sends signal to actuator to switch lights on. 6. If light level >= threshold, microprocessor sends signal to turn/keep lights off. 7. The process is continuous/runs in an infinite loop.

准备好测试自己了吗?

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

练习此课题

卷二 Algorithms, Programming and Logic

Answer all questions. Write answers in pseudocode, SQL, or flow diagrams. Show clearly any tracing tables or working.
10 题目 · 53
题目 1 · matching
3
A software developer is designing a flowchart for an automated library kiosk. Match each of the following Flowchart actions to its correct Flowchart symbol shape. Flowchart action: 1. Reading a barcode scanner input to identify a book. 2. Testing if the user has an outstanding fine. 3. Decrementing the available copies variable by 1. Flowchart symbol shape: - Rectangle - Parallelogram - Diamond - Oval
查看答案详解

解题

1. Reading a barcode scanner is an input operation, represented by a Parallelogram. 2. Testing a condition is a decision operation, represented by a Diamond. 3. Decrementing a variable is a processing/calculation operation, represented by a Rectangle.

评分标准

One mark for each correct link: - 'Reading a barcode...' linked to Parallelogram [1 mark] - 'Testing if the user...' linked to Diamond [1 mark] - 'Decrementing the available...' linked to Rectangle [1 mark]
题目 2 · matching
3
Match each of the following Boolean descriptions to the correct Logic Gate. Boolean description: 1. The output is 1 only when both inputs are different. 2. The output is 0 only when both inputs are 1. 3. The output is 1 only when both inputs are 0. Logic Gate: - XOR - NOR - NAND - AND
查看答案详解

解题

1. An exclusive OR (XOR) gate outputs 1 only when its inputs are different. 2. A NAND gate outputs 0 only when both of its inputs are 1. 3. A NOR gate outputs 1 only when both of its inputs are 0.

评分标准

One mark for each correct match: - Description 1 linked to 'XOR' [1 mark] - Description 2 linked to 'NAND' [1 mark] - Description 3 linked to 'NOR' [1 mark]
题目 3 · Dry Run Trace Table
6
A one-dimensional (1D) array named Values[] contains the following six numbers: [12, 8, 15, 3, 10, 7] at index positions 1 to 6.

Complete the trace table for this pseudocode algorithm:

Total ← 0
Index ← 1
Flag ← FALSE

WHILE Index <= 6 AND Flag = FALSE
IF Values[Index] MOD 2 = 0
THEN
Total ← Total + Values[Index]
ELSE
IF Values[Index] > 10
THEN
Flag ← TRUE
ENDIF
ENDIF
Index ← Index + 1
ENDWHILE

OUTPUT "Total: ", Total
OUTPUT "Final Index: ", Index

Trace Table:
| Total | Index | Flag | Values[Index] | OUTPUT |
| :---: | :---: | :--: | :-----------: | :----: |
| | | | | |
查看答案详解

解题

Let's trace the algorithm step-by-step:

1. **Initialization**:
- `Total` is set to 0.
- `Index` is set to 1.
- `Flag` is set to `FALSE`.

2. **First Iteration** (`Index = 1`):
- Loop condition `Index <= 6 AND Flag = FALSE` (1 <= 6 AND FALSE = FALSE) is True.
- `Values[1]` is 12.
- `12 MOD 2 = 0` is True.
- `Total` becomes `Total + 12 = 12`.
- `Index` becomes `1 + 1 = 2`.

3. **Second Iteration** (`Index = 2`):
- Loop condition (2 <= 6 AND FALSE = FALSE) is True.
- `Values[2]` is 8.
- `8 MOD 2 = 0` is True.
- `Total` becomes `12 + 8 = 20`.
- `Index` becomes `2 + 1 = 3`.

4. **Third Iteration** (`Index = 3`):
- Loop condition (3 <= 6 AND FALSE = FALSE) is True.
- `Values[3]` is 15.
- `15 MOD 2 = 0` is False.
- Nested check: `Values[3] > 10` (15 > 10) is True.
- `Flag` becomes `TRUE`.
- `Index` becomes `3 + 1 = 4`.

5. **Loop Termination Check** (`Index = 4`):
- Loop condition `Index <= 6 AND Flag = FALSE` (4 <= 6 AND TRUE = FALSE) is False. Loop terminates.

6. **Outputs**:
- `OUTPUT "Total: ", Total` displays `Total: 20`.
- `OUTPUT "Final Index: ", Index` displays `Final Index: 4`.

评分标准

One mark is awarded for each correct step/value (up to 6 marks total):
- **1 mark** for correct initial values of `Total` (0), `Index` (1), and `Flag` (FALSE).
- **1 mark** for correct first iteration trace: `Values[Index]` = 12, `Total` = 12, `Index` = 2.
- **1 mark** for correct second iteration trace: `Values[Index]` = 8, `Total` = 20, `Index` = 3.
- **1 mark** for correct third iteration trace: `Values[Index]` = 15, `Flag` = TRUE, `Index` = 4.
- **1 mark** for correctly terminating the loop without further rows added for indices 5 or 6.
- **1 mark** for both correct outputs exactly matching the variables' final states ("Total: 20" and "Final Index: 4").
题目 4 · Pseudocode analysis & correction
4.5
This pseudocode algorithm is intended to find the maximum value in an array of 100 positive integers.

01 DECLARE Numbers : ARRAY[1:100] OF INTEGER
02 DECLARE Max : INTEGER
03 DECLARE Index : INTEGER
04 Max <- 9999
05 FOR Index <- 1 TO 100 STEP -1
06 IF Numbers[Index] < Max THEN
07 Max <- Index
08 ENDIF
09 NEXT Index
10 OUTPUT "The maximum value is ", Max

Identify the line numbers of the four errors in the pseudocode and suggest corrections.
查看答案详解

解题

01 DECLARE Numbers : ARRAY[1:100] OF INTEGER
02 DECLARE Max : INTEGER
03 DECLARE Index : INTEGER
04 Max <- 0
05 FOR Index <- 1 TO 100
06 IF Numbers[Index] > Max THEN
07 Max <- Numbers[Index]
08 ENDIF
09 NEXT Index
10 OUTPUT "The maximum value is ", Max

评分标准

- 1.0 mark: Correctly identifying Line 04 and changing 9999 to 0, -1, or Numbers[1]
- 1.0 mark: Correctly identifying Line 05 and removing STEP -1 (or changing it to STEP 1)
- 1.0 mark: Correctly identifying Line 06 and changing '<' to '>'
- 1.5 marks: Correctly identifying Line 07 and changing Index to Numbers[Index]
题目 5 · Pseudocode analysis & correction
4.5
This pseudocode algorithm is intended to perform a linear search to find if a target name exists within a 1D array of 50 student names.

01 DECLARE Names : ARRAY[1:50] OF STRING
02 DECLARE Target : STRING
03 DECLARE Found : BOOLEAN
04 DECLARE I : INTEGER
05 Found <- TRUE
06 I <- 1
07 INPUT Target
08 WHILE (Found = FALSE) AND (I < 50) DO
09 IF Names[I] <> Target THEN
10 Found <- TRUE
11 ENDIF
12 I <- I - 1
13 ENDWHILE

Identify the line numbers of the four errors in the pseudocode and suggest corrections.
查看答案详解

解题

01 DECLARE Names : ARRAY[1:50] OF STRING
02 DECLARE Target : STRING
03 DECLARE Found : BOOLEAN
04 DECLARE I : INTEGER
05 Found <- FALSE
06 I <- 1
07 INPUT Target
08 WHILE (Found = FALSE) AND (I <= 50) DO
09 IF Names[I] = Target THEN
10 Found <- TRUE
11 ENDIF
12 I <- I + 1
13 ENDWHILE

评分标准

- 1.0 mark: Correctly identifying Line 05 and changing TRUE to FALSE
- 1.5 marks: Correctly identifying Line 08 and changing '< 50' to '<= 50' (or '< 51') to include the last element
- 1.0 mark: Correctly identifying Line 09 and changing '<>' to '='
- 1.0 mark: Correctly identifying Line 12 and changing 'I <- I - 1' to 'I <- I + 1'
题目 6 · Pseudocode analysis & correction
4.5
This pseudocode algorithm is intended to process a 1D array of 80 exam marks (integers from 0 to 100) and count how many students passed (marks of 50 or above) and how many failed (marks below 50).

01 DECLARE Marks : ARRAY[1:80] OF INTEGER
02 DECLARE PassCount : INTEGER
03 DECLARE FailCount : INTEGER
04 DECLARE Index : INTEGER
05 PassCount <- 0
06 FailCount <- 0
07 FOR Index <- 1 TO 80
08 IF Marks[Index] > 50 THEN
09 PassCount <- PassCount + Index
10 ELSE
11 FailCount <- FailCount - 1
12 ENDIF
13 NEXT PassCount

Identify the line numbers of the four errors in the pseudocode and suggest corrections.
查看答案详解

解题

01 DECLARE Marks : ARRAY[1:80] OF INTEGER
02 DECLARE PassCount : INTEGER
03 DECLARE FailCount : INTEGER
04 DECLARE Index : INTEGER
05 PassCount <- 0
06 FailCount <- 0
07 FOR Index <- 1 TO 80
08 IF Marks[Index] >= 50 THEN
09 PassCount <- PassCount + 1
10 ELSE
11 FailCount <- FailCount + 1
12 ENDIF
13 NEXT Index

评分标准

- 1.0 mark: Correctly identifying Line 08 and changing '>' to '>='
- 1.0 mark: Correctly identifying Line 09 and changing '+ Index' to '+ 1'
- 1.0 mark: Correctly identifying Line 11 and changing '- 1' to '+ 1'
- 1.5 marks: Correctly identifying Line 13 and changing 'PassCount' to 'Index' to match the loop variable
题目 7 · Pseudocode analysis & correction
4.5
This pseudocode algorithm is intended to calculate the mathematical factorial of a positive integer input by the user (for example, if the input is 4, the output should be 24, which is \(4 \times 3 \times 2 \times 1\)).

01 DECLARE Num : INTEGER
02 DECLARE Factorial : INTEGER
03 DECLARE Count : INTEGER
04 INPUT Num
05 Factorial <- 0
06 Count <- 1
07 WHILE Count < Num DO
08 Factorial <- Factorial + Count
09 Count <- Count - 1
10 ENDWHILE
11 OUTPUT "The factorial is ", Factorial

Identify the line numbers of the four errors in the pseudocode and suggest corrections.
查看答案详解

解题

01 DECLARE Num : INTEGER
02 DECLARE Factorial : INTEGER
03 DECLARE Count : INTEGER
04 INPUT Num
05 Factorial <- 1
06 Count <- 1
07 WHILE Count <= Num DO
08 Factorial <- Factorial * Count
09 Count <- Count + 1
10 ENDWHILE
11 OUTPUT "The factorial is ", Factorial

评分标准

- 1.0 mark: Correctly identifying Line 05 and changing 0 to 1
- 1.0 mark: Correctly identifying Line 07 and changing '<' to '<='
- 1.0 mark: Correctly identifying Line 08 and changing '+' to '*'
- 1.5 marks: Correctly identifying Line 09 and changing '- 1' to '+ 1' (to increment the counter and avoid an infinite loop)
题目 8 · Database/SQL construction
4
A database table called Books stores details of novels in a local library.

| BookID | Title | Author | Genre | PubYear | Available |
|---|---|---|---|---|---|
| BK101 | The Last Forest | J. Shaw | Sci-Fi | 2018 | Y |
| BK102 | Stormy Night | M. Diaz | Mystery | 2012 | N |
| BK103 | Cyber Dawn | J. Shaw | Sci-Fi | 2021 | Y |
| BK104 | Hidden Truths | A. Vance | Drama | 2015 | Y |
| BK105 | Lost in Time | M. Diaz | Sci-Fi | 2019 | N |
| BK106 | Golden Age | K. Patel | History | 2020 | Y |

Write a structured query language (SQL) statement to display only the Title and PubYear of all books in the 'Sci-Fi' genre that are currently available ('Y'). The output should be sorted by PubYear in ascending order.
查看答案详解

解题

We need to select only 'Title' and 'PubYear' fields from the 'Books' table. The criteria are that the 'Genre' must be 'Sci-Fi' and the 'Available' status must be 'Y'. Finally, the results must be ordered by the 'PubYear' field in ascending order.

SQL query:
SELECT Title, PubYear
FROM Books
WHERE Genre = 'Sci-Fi' AND Available = 'Y'
ORDER BY PubYear;

评分标准

1 mark: SELECT Title, PubYear
1 mark: FROM Books
1 mark: WHERE Genre = 'Sci-Fi' AND Available = 'Y'
1 mark: ORDER BY PubYear
题目 9 · Database/SQL construction
4
A database table called Members stores details of participants at a sports club.

| MemberID | LastName | Age | Sport | MonthlyFee | Active |
|---|---|---|---|---|---|
| MB04 | Alvarez | 14 | Tennis | 35.00 | Y |
| MB11 | Harrison | 18 | Squash | 45.00 | Y |
| MB15 | Alvarez | 16 | Tennis | 32.00 | N |
| MB22 | Patel | 15 | Swimming | 38.00 | Y |
| MB31 | Chen | 17 | Squash | 42.00 | Y |
| MB40 | Harrison | 12 | Swimming | 40.00 | N |

Give the output that would be produced by the structured query language (SQL) statement:

SELECT LastName, Sport, MonthlyFee
FROM Members
WHERE Age >= 15 AND Active = 'Y'
ORDER BY MonthlyFee DESC;
查看答案详解

解题

First, filter the table by the condition 'Age >= 15 AND Active = Y':
- MB11 (Harrison, 18, Squash, 45.00, Y) - Meets condition.
- MB15 (Alvarez, 16, Tennis, 32.00, N) - Fails (Active is N).
- MB22 (Patel, 15, Swimming, 38.00, Y) - Meets condition.
- MB31 (Chen, 17, Squash, 42.00, Y) - Meets condition.
- MB04 and MB40 fail age limit.

Now, display only 'LastName', 'Sport', and 'MonthlyFee' for the selected members, sorted by 'MonthlyFee' in descending order (highest to lowest):
1. Harrison Squash 45.00
2. Chen Squash 42.00
3. Patel Swimming 38.00

评分标准

1 mark: Correct fields (LastName, Sport, MonthlyFee) listed.
1 mark: Only the correct records (MB11, MB31, MB22) are selected.
1 mark: Records correctly sorted by MonthlyFee in descending order.
1 mark: No extraneous data or incorrect fields shown.
题目 10 · practical
15
A one-dimensional (1D) array `Stations[]` contains the names of 12 weather stations in a region.

A two-dimensional (2D) array `RainfallData[]` stores, for each weather station, the daily rainfall (in mm) for 5 days (Monday to Friday, in columns 1 to 5) and the total weekly rainfall (in column 6).

The position of any station's data is the same in both arrays. For example, the data in index 3 of `RainfallData[]` belongs to the weather station in index 3 of `Stations[]`.

The array data will be used to find the weather station with the highest recorded rainfall.

The variable `MaxRain` stores the maximum allowable daily rainfall limit used for validation.

Write a program that meets the following requirements:
- allows the maximum daily rainfall limit `MaxRain` to be input and stored, with a minimum value of 50 mm and a maximum value of 200 mm
- allows the names of the 12 weather stations to be input and stored
- allows the daily rainfall for 5 days (Monday to Friday) to be input and stored for each station
- validates each daily rainfall input to ensure it is not negative and does not exceed the limit `MaxRain`
- calculates and stores the total weekly rainfall for each station in column 6 of `RainfallData[]`
- sorts the array `RainfallData[]` into descending order of total weekly rainfall, ensuring the corresponding parallel array `Stations[]` is kept in the same order
- determines how many stations have the highest weekly rainfall (handling any potential ties)
- outputs the name(s) of the winning weather station(s) along with the highest total weekly rainfall achieved.

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

You do not need to declare any arrays, variables or constants; you may assume that this has already been done.

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

解题

// Input and validate the maximum daily rainfall limit
REPEAT
OUTPUT "Enter the maximum daily rainfall limit (50 to 200 mm): "
INPUT MaxRain
UNTIL MaxRain >= 50 AND MaxRain <= 200

// Loop to input names and rainfall data for 12 stations
FOR StationLoop <- 1 TO 12
OUTPUT "Enter the name of station number ", StationLoop, ": "
INPUT Stations[StationLoop]

WeeklyTotal <- 0

// Input daily rainfall for 5 days
FOR DayLoop <- 1 TO 5
REPEAT
OUTPUT "Enter rainfall (in mm) for day ", DayLoop, " at ", Stations[StationLoop], ": "
INPUT DailyRain
IF DailyRain < 0 OR DailyRain > MaxRain THEN
OUTPUT "Invalid input. Rainfall must be between 0 and ", MaxRain, " mm."
ENDIF
UNTIL DailyRain >= 0 AND DailyRain <= MaxRain

// Store valid daily rainfall in the 2D array
RainfallData[StationLoop, DayLoop] <- DailyRain
WeeklyTotal <- WeeklyTotal + DailyRain
NEXT DayLoop

// Store weekly total in column 6 of 2D array
RainfallData[StationLoop, 6] <- WeeklyTotal
NEXT StationLoop

// Bubble sort to order stations by weekly total rainfall descending (column 6)
Flag <- TRUE
WHILE Flag DO
Flag <- FALSE
FOR Sort <- 1 TO 11
// Compare total rainfall of adjacent elements
IF RainfallData[Sort, 6] < RainfallData[Sort + 1, 6] THEN
// Swap station names
TempStation <- Stations[Sort]
Stations[Sort] <- Stations[Sort + 1]
Stations[Sort + 1] <- TempStation

// Swap all rainfall data (columns 1 to 6)
FOR Col <- 1 TO 6
TempData <- RainfallData[Sort, Col]
RainfallData[Sort, Col] <- RainfallData[Sort + 1, Col]
RainfallData[Sort + 1, Col] <- TempData
NEXT Col
Flag <- TRUE
ENDIF
NEXT Sort
ENDWHILE

// Detect highest rainfall and count ties
HighestRain <- RainfallData[1, 6]
CountTies <- 1
Finish <- FALSE
REPEAT
IF RainfallData[CountTies, 6] = RainfallData[CountTies + 1, 6] THEN
CountTies <- CountTies + 1
ELSE
Finish <- TRUE
ENDIF
UNTIL Finish OR CountTies = 12

// Output the results
FOR OutLoop <- 1 TO CountTies
OUTPUT "Weather station with the highest rainfall: ", Stations[OutLoop]
NEXT OutLoop
OUTPUT "Total rainfall recorded: ", HighestRain, " mm"

评分标准

AO2: Apply (Max 9 marks)
- R1: Input and range-validate MaxRain between 50 and 200 (1 mark); input station names and daily rainfall inside structured nested loops (1 mark); validate daily rainfall between 0 and MaxRain with appropriate error messages (1 mark).
- R2: Totalling rainfall over the 5-day loop correctly (1 mark) and storing the final sum in the 6th column of RainfallData[] (1 mark).
- R3: Bubble sort outer loop/conditional structure (1 mark); correct sorting comparison key on column 6 (1 mark); swapping parallel station name list elements (1 mark); swapping all 1 to 6 data columns of the RainfallData array (1 mark).

AO3: Provide solutions (Max 6 marks)
- Comments: Fully and relevantly commented code explaining blocks (2 marks); partially commented (1 mark).
- Identifiers: Consistent use of descriptive camelCase or PascalCase identifier names (1 mark).
- Logic & Ties: Correct search logic for finding maximum (1 mark); robust loop logic checking adjacent equal items to handle multiple tied highest values (1 mark); final clear and labeled output messages (1 mark).

想知道自己有几分把握?

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

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

免费开始练习