Cambridge IAS-Level · Thinka 原創模擬試題

2025 Cambridge IAS-Level Computer Science (9618) 模擬試題連答案詳解

Thinka Nov 2025 (V2) Cambridge International A Level-Style Mock — Computer Science (9618)

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

卷一 Theory Fundamentals

Answer all questions. Calculators must not be used.
23 題目 · 67
題目 1 · grid
2
An operating system and utility software are both types of system software. Identify whether each of the following tasks is primarily a function of the Operating System or a Utility Program:

1. Allocating processor time to active processes
2. Reorganizing files on a hard disk into contiguous sectors
3. Managing peripheral devices using device drivers
4. Reducing the file size of an archive to save storage space
查看答案詳解

解題

1. Allocating processor time is process scheduling, which is a core task managed by the Operating System.
2. Reorganizing files on a hard disk into contiguous sectors is disk defragmentation, which is performed by a Utility Program.
3. Managing peripheral devices using device drivers is input/output control, which is managed by the Operating System.
4. Reducing the file size of an archive is data compression, which is performed by a Utility Program.

評分準則

2 marks for all 4 matches correct.
1 mark for 2 or 3 matches correct.
0 marks for 0 or 1 match correct.
題目 2 · grid
2
An operating system and utility software are both types of system software. Identify whether each of the following tasks is primarily a function of the Operating System or a Utility Program:

1. Allocating processor time to active processes
2. Reorganizing files on a hard disk to contiguous sectors
3. Managing peripheral devices using device drivers
4. Reducing the file size of an archive to save storage space
查看答案詳解

解題

1. Allocating processor time is process scheduling, which is a core task managed by the Operating System.
2. Reorganizing files on a hard disk into contiguous sectors is disk defragmentation, which is performed by a Utility Program.
3. Managing peripheral devices using device drivers is input/output control, which is managed by the Operating System.
4. Reducing the file size of an archive is data compression, which is performed by a Utility Program.

評分準則

2 marks for all 4 matches correct.
1 mark for 2 or 3 matches correct.
0 marks for 0 or 1 match correct.
題目 3 · Short Definition and Description
3
Describe how Run-Length Encoding (RLE) is used to compress data. Your description should include how the data is stored and one scenario where this compression method is highly effective.
查看答案詳解

解題

Run-Length Encoding (RLE) compresses data by:
1. Identifying consecutive sequences of identical data values (runs).
2. Replacing these runs with a single instance of the data value and a count of its consecutive repetitions (e.g., 'AAAAABBB' becomes '5A3B').
3. It is highly effective when compressing files with high redundancy, such as simple bitmap images with large areas of flat solid color.

評分準則

Award up to 3 marks:
- 1 mark: Identifies that RLE looks for consecutive identical data elements / runs of data.
- 1 mark: Explains that data is stored as a pair of values: the data value and its frequency / count of occurrences.
- 1 mark: Gives a valid scenario where it is highly effective (e.g., simple graphics with solid colors, black and white document scans, text with long runs of spaces).
題目 4 · Short Definition and Description
3
Describe how a buffer is used during the real-time streaming of video content over the internet.
查看答案詳解

解題

A buffer is a dedicated, temporary area of memory. During streaming, data packets arriving from the server are stored here first. The video player reads data from the buffer rather than directly from the network stream. This creates a cushion that absorbs network latency/jitter, preventing the video from stuttering or pausing (buffering) as long as the download rate matches or exceeds the playback rate.

評分準則

Award up to 3 marks:
- 1 mark: Identifies the buffer as a temporary storage area / memory queue on the receiving device.
- 1 mark: Explains that data packets are stored in the buffer before being decoded/played.
- 1 mark: Explains the purpose: to absorb network fluctuations / variations in transmission speed / jitter to ensure smooth, uninterrupted playback.
題目 5 · Short Definition and Description
3
Describe the role of the Program Counter (PC) register during the fetch stage of the Fetch-Execute cycle.
查看答案詳解

解題

During the fetch stage:
1. The PC holds the memory address of the next instruction to be fetched.
2. This address is copied from the PC to the Memory Address Register (MAR).
3. The PC is then incremented to point to the next instruction in sequence.

評分準則

Award up to 3 marks:
- 1 mark: States that the PC holds the address of the next instruction to be fetched / executed.
- 1 mark: States that this address is copied from the PC to the Memory Address Register (MAR).
- 1 mark: States that the PC is incremented (to point to the next sequential instruction address).
題目 6 · Short Definition and Description
3
Describe how a checksum is used to verify that data has not been corrupted during transmission across a network.
查看答案詳解

解題

1. The sender uses an algorithm to compute a checksum based on the binary content of the data before transmission.
2. The calculated checksum is sent along with the data payload.
3. The receiver recalculates the checksum from the received data using the same algorithm and compares it with the received checksum. A mismatch indicates data corruption during transit.

評分準則

Award up to 3 marks:
- 1 mark: Sender calculates a checksum value using an algorithm based on the data block/bits before transmission.
- 1 mark: The checksum value is sent together with the data block.
- 1 mark: Receiver recalculates the checksum using the same algorithm and compares it with the received checksum (mismatch = error/corruption).
題目 7 · short answer
3

An assembly language program is written using the standard Cambridge International instruction set. The program uses the following memory locations and initial states:

  • COUNT contains the denary value 3
  • TEMP contains the denary value 0
  • SUM contains the denary value 0

The program instructions are as follows:

LDD COUNT
STO TEMP
LDI 0
STO SUM
LOOP: LDD SUM
ADD TEMP
STO SUM
LDD TEMP
DEC ACC
STO TEMP
CMP #0
JPN LOOP
LDD SUM
END

Trace the program and state the final denary values of:

  1. The Accumulator (ACC)
  2. Memory location TEMP
  3. Memory location SUM
查看答案詳解

解題

Let's trace the execution of the assembly program step-by-step:




  1. LDD COUNT: ACC is loaded with the content of COUNT, so ACC = 3.

  2. STO TEMP: The value in ACC is stored in TEMP, so TEMP = 3.

  3. LDI 0: ACC is loaded with the immediate value 0, so ACC = 0.

  4. STO SUM: The value in ACC is stored in SUM, so SUM = 0.



First Iteration of LOOP:



  • LDD SUM: ACC is loaded with SUM (0).

  • ADD TEMP: ACC is added to TEMP (0 + 3 = 3), so ACC = 3.

  • STO SUM: Store ACC to SUM, so SUM = 3.

  • LDD TEMP: ACC is loaded with TEMP (3).

  • DEC ACC: Decrement ACC (3 - 1 = 2), so ACC = 2.

  • STO TEMP: Store ACC to TEMP, so TEMP = 2.

  • CMP #0: Compare ACC (2) to 0. They are not equal.

  • JPN LOOP: Since the comparison is not equal, jump back to LOOP.



Second Iteration of LOOP:



  • LDD SUM: ACC is loaded with SUM (3).

  • ADD TEMP: ACC is added to TEMP (3 + 2 = 5), so ACC = 5.

  • STO SUM: Store ACC to SUM, so SUM = 5.

  • LDD TEMP: ACC is loaded with TEMP (2).

  • DEC ACC: Decrement ACC (2 - 1 = 1), so ACC = 1.

  • STO TEMP: Store ACC to TEMP, so TEMP = 1.

  • CMP #0: Compare ACC (1) to 0. They are not equal.

  • JPN LOOP: Since the comparison is not equal, jump back to LOOP.



Third Iteration of LOOP:



  • LDD SUM: ACC is loaded with SUM (5).

  • ADD TEMP: ACC is added to TEMP (5 + 1 = 6), so ACC = 6.

  • STO SUM: Store ACC to SUM, so SUM = 6.

  • LDD TEMP: ACC is loaded with TEMP (1).

  • DEC ACC: Decrement ACC (1 - 1 = 0), so ACC = 0.

  • STO TEMP: Store ACC to TEMP, so TEMP = 0.

  • CMP #0: Compare ACC (0) to 0. They are equal.

  • JPN LOOP: No jump, since the comparison is equal.



Post-loop Execution:



  • LDD SUM: ACC is loaded with SUM (6), so ACC = 6.

  • END: Program terminates.

評分準則

Award 1 mark for each correct final value (Max 3 marks):
- 1 mark for ACC = 6
- 1 mark for TEMP = 0
- 1 mark for SUM = 6
題目 8 · short_answer
4
A travel agency database needs a new table to store information about airports. Write an SQL DDL script to create the table Airport with the following requirements: - AirportCode: text up to 3 characters, which is the primary key. - AirportName: text up to 50 characters, which cannot be left empty (must be NOT NULL). - Country: text up to 30 characters. - Capacity: an integer value.
查看答案詳解

解題

The CREATE TABLE statement is used to define a new table. Inside the parentheses, we declare the field names followed by their data types and optional constraints. AirportCode is defined as VARCHAR(3) with the PRIMARY KEY constraint. AirportName is defined as VARCHAR(50) with the NOT NULL constraint to ensure it cannot be blank. Country is defined as VARCHAR(30), and Capacity is defined as INT or INTEGER. The statement ends with a closing parenthesis and a semicolon.

評分準則

1 mark: Correct CREATE TABLE Airport ( ... ); structure. 1 mark: AirportCode defined with appropriate text data type (e.g. VARCHAR(3) or CHAR(3)) and set as PRIMARY KEY. 1 mark: AirportName defined with appropriate text data type (e.g. VARCHAR(50)) and NOT NULL constraint. 1 mark: Country and Capacity defined with appropriate data types (e.g. VARCHAR(30) and INT/INTEGER respectively).
題目 9 · short_answer
4
A database contains two tables with the following schemas: Customer(CustomerID, FirstName, LastName, Country) and Booking(BookingID, CustomerID, BookingDate, TotalAmount). Write an SQL query to retrieve the FirstName, LastName, and TotalAmount of all bookings made by customers who live in 'Canada'. The final output must be sorted by TotalAmount in descending order.
查看答案詳解

解題

To construct the query: 1. SELECT the requested columns: FirstName, LastName, and TotalAmount. 2. Use FROM and INNER JOIN (or an implicit join in WHERE) to link the Customer and Booking tables using the common field CustomerID. 3. Apply the filter WHERE Country = 'Canada' to restrict the results. 4. Sort the output using ORDER BY TotalAmount DESC to meet the descending order requirement.

評分準則

1 mark: SELECT FirstName, LastName, TotalAmount. 1 mark: Correct table join linking Customer and Booking tables on CustomerID (either INNER JOIN ... ON Customer.CustomerID = Booking.CustomerID or implicit join in WHERE clause). 1 mark: Correct filter WHERE Country = 'Canada' (or Customer.Country = 'Canada'). 1 mark: Correct sorting ORDER BY TotalAmount DESC.
題目 10 · short_answer
4
A school database has a table named Device with the following attributes: DeviceID, DeviceType, PurchaseDate, Price, RoomID. Write an SQL query to display the RoomID and the total price of all devices in that room. The query must only include rooms where the total price of all devices exceeds 1500.
查看答案詳解

解題

To solve this: 1. We must select the RoomID and calculate the sum of the prices using the aggregation function SUM(Price). 2. Since we are using an aggregate function alongside a standard column (RoomID), we must use GROUP BY RoomID to group the records. 3. To filter groups based on the aggregated value, we must use the HAVING clause instead of the WHERE clause: HAVING SUM(Price) > 1500.

評分準則

1 mark: SELECT RoomID, SUM(Price) (or SUM(Price) with an alias). 1 mark: FROM Device. 1 mark: GROUP BY RoomID. 1 mark: HAVING SUM(Price) > 1500 (Reject the use of WHERE for the aggregate condition).
題目 11 · short_answer
3
A small design studio with 10 computers is considering changing their network model from a Peer-to-Peer (P2P) architecture to a Client-Server architecture. State three advantages for the studio of adopting a Client-Server model instead of keeping their Peer-to-Peer model.
查看答案詳解

解題

1. Centralised backup: All files are stored on the central server, making it straightforward to perform regular backups from a single location rather than backing up individual workstations. 2. Centralised security: User access permissions, antivirus software, and system updates can be managed and deployed centrally by an administrator. 3. Centralised file storage: Design assets are kept in a single depository, reducing data redundancy and preventing version control issues among designers.

評分準則

Award 1 mark per valid advantage up to a maximum of 3 marks:
- Centralised backup (easier to back up data from one location)
- Centralised security / user access permissions control
- Centralised software installation / updates management
- Better performance/efficiency when accessing shared files or high-demand resources
- Easier to scale the network (add more workstations without losing structure)
題目 12 · short_answer
3
Explain three differences between video-on-demand bit streaming and real-time bit streaming.
查看答案詳解

解題

1. Source: On-demand streaming uses media files that are pre-recorded and already stored on a web server. Real-time streaming processes and broadcasts a live feed of an event as it occurs. 2. Playback Control: In video-on-demand, users can fast-forward, rewind, or pause because the entire file exists. In real-time streaming, users cannot fast-forward into the future; they are limited to the live point (though some services allow pausing and rewinding to a buffer limit). 3. Latency and Buffering: On-demand can buffer a significant portion of the video file in advance on the client device. Real-time streaming requires ultra-low latency, meaning the buffer must be kept small to keep the stream as close to 'live' as possible, making it more vulnerable to network jitter.

評分準則

Award 1 mark per valid difference up to a maximum of 3 marks:
- On-demand streams pre-recorded files vs Real-time streams live events.
- On-demand allows full control (pause, rewind, fast-forward) vs Real-time has limited control (cannot fast-forward past the live point).
- On-demand can use a large buffer to prevent buffering pauses vs Real-time requires a minimal buffer to reduce transmission latency.
- On-demand files can be pre-compressed/optimized in advance vs Real-time encoding must happen dynamically on-the-fly.
題目 13 · short_answer
3
Identify three differences between an IPv4 address and an IPv6 address.
查看答案詳解

解題

1. Bit Length: IPv4 uses 32-bit addresses, whereas IPv6 uses 128-bit addresses. 2. Notation: IPv4 is written as four decimal numbers separated by dots (e.g., 192.168.1.1), while IPv6 is written as eight groups of four hexadecimal digits separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). 3. Capacity: IPv4 yields about 4.3 billion unique addresses, which are now depleted. IPv6 yields roughly \(3.4 \times 10^{38}\) addresses, ensuring a virtually inexhaustible supply.

評分準則

Award 1 mark per valid difference up to a maximum of 3 marks:
- IPv4 is 32-bit vs IPv6 is 128-bit.
- IPv4 uses dotted-decimal format vs IPv6 uses colon-hexadecimal format.
- IPv4 has 4 groups/octets vs IPv6 has 8 groups.
- IPv4 has a much smaller address space (approx. 4.3 billion) vs IPv6 has a vastly larger address space (approx. \(3.4 \times 10^{38}\)).
- IPv4 requires Network Address Translation (NAT) to preserve addresses on local networks vs IPv6 has enough global addresses to not require NAT.
題目 14 · short_answer
3
Describe three functions performed by a router when routing data packets between a local area network (LAN) and the internet (WAN).
查看答案詳解

解題

1. Inspecting Packet Headers: The router reads the destination IP address contained in the header of incoming data packets to see where they need to go. 2. Determining Paths (Routing): It maintains and consults a routing table to dynamically select the most efficient path or next node (hop) for forwarding the packet. 3. Network Address Translation (NAT): Since local devices use private IP addresses which cannot be routed over the public internet, the router translates these private IP addresses to its single public IP address when sending packets out, and does the reverse for incoming response packets.

評分準則

Award 1 mark per valid function described up to a maximum of 3 marks:
- Receives packets and reads/inspects destination IP address in the header.
- Uses/maintains a routing table to choose the most efficient path/route/next hop.
- Directs/forwards packets across different networks towards their destination.
- Performs Network Address Translation (NAT) (translates private IP addresses to public, and vice versa).
- Can act as a gateway/firewall to filter traffic or block unauthorized access.
題目 15 · short_answer
2
Represent the negative denary value \(-54\) as an 8-bit two's complement integer. Show your working.
查看答案詳解

解題

To represent \(-54\) in 8-bit two's complement:
1. Convert the positive value \(+54\) to binary: \(00110110\).
2. Invert all the bits to get the one's complement: \(11001001\).
3. Add 1 to the result: \(11001001 + 1 = 11001010\).

評分準則

1 mark: Correct binary representation of \(+54\) (\(00110110\)) or correct one's complement (\(11001001\)).
1 mark: Correct final 8-bit two's complement binary value (\(11001010\)).
題目 16 · short_answer
2
An RGB colour is represented by the hexadecimal code `#A3C20F`. State the 8-bit binary representation of the green (G) component of this colour.
查看答案詳解

解題

The hexadecimal code is divided into three parts: Red (R), Green (G), and Blue (B). Each part is 2 hexadecimal digits.
- Red: `A3`
- Green: `C2`
- Blue: `0F`

The green component is `C2` in hexadecimal.
Converting `C2` to 8-bit binary:
- `C` in binary is `1100`
- `2` in binary is `0010`
Combining these gives: `11000010`.

評分準則

1 mark: Correctly identifying the green component in hexadecimal as `C2` (or converting one of the hex nibbles correctly).
1 mark: Correct final 8-bit binary string `11000010`.
題目 17 · short_answer
2
A temperature sensor records a value of \(308.5\). Represent this numerical value in packed Binary Coded Decimal (BCD) format.
查看答案詳解

解題

In packed Binary Coded Decimal (BCD), each individual denary digit is represented using a 4-bit binary value (a nibble).
For the value \(308.5\), the digits to represent are `3`, `0`, `8`, and `5`:
- `3` = `0011`
- `0` = `0000`
- `8` = `1000`
- `5` = `0101`
Combining these nibbles in sequence gives: `0011000010000101`.

評分準則

1 mark: Correctly converting at least two of the digits to their respective 4-bit BCD representations.
1 mark: Correct complete 16-bit sequence: `0011000010000101` (accept space-separated nibbles).
題目 18 · short_answer
2
A sound track is recorded mono (1 channel) for a duration of 5 seconds. The sampling rate is 4,000 Hz, and the sampling resolution is 8 bits. Calculate the minimum file size of this recording in bytes. Show your working.
查看答案詳解

解題

Using the file size formula:
File size (bits) = Sample Rate \(\times\) Resolution \(\times\) Time \(\times\) Channels
File size (bits) = \(4,000 \text{ Hz} \times 8 \text{ bits} \times 5 \text{ seconds} \times 1 = 160,000 \text{ bits}\)
Converting bits to bytes:
\(160,000 \text{ bits} / 8 = 20,000 \text{ bytes}\).
Alternatively, since 8 bits = 1 byte:
\(4,000 \text{ samples/sec} \times 5 \text{ seconds} = 20,000 \text{ samples}\). Each sample is 1 byte, so \(20,000 \text{ bytes}\).

評分準則

1 mark: Correct method shown to calculate file size (e.g., multiplying \(4,000 \times 5 \times 8\) or showing conversion to bytes).
1 mark: Correct final answer of 20,000 (bytes).
題目 19 · short_answer
2
In the ASCII character set, the uppercase character 'D' is represented by the denary value 68. Determine the 8-bit binary representation of the uppercase character 'I'. Show your working.
查看答案詳解

解題

First, find the denary value of 'I' based on 'D' = 68:
- 'D' = 68
- 'E' = 69
- 'F' = 70
- 'G' = 71
- 'H' = 72
- 'I' = 73
Next, convert the denary value 73 to 8-bit binary:
\(73 = 64 + 8 + 1 = 2^6 + 2^3 + 2^0\)
This corresponds to the binary string: `01001001`.

評分準則

1 mark: Correctly determining that the denary value of 'I' is 73.
1 mark: Correct 8-bit binary representation `01001001`.
題目 20 · short_answer
2
A bitmap image has a row containing the following sequence of pixels, where W represents white and B represents black: `WWWWWWBBBBWWWWWW`. Show how this sequence would be compressed using Run-Length Encoding (RLE).
查看答案詳解

解題

Run-Length Encoding (RLE) compresses consecutive identical data items by replacing them with a single value and a count.
The sequence consists of:
- 6 consecutive W pixels
- 4 consecutive B pixels
- 6 consecutive W pixels
This yields the compressed sequence: `6W 4B 6W` (or `W6 B4 W6`, or with delimiters such as `6, W, 4, B, 6, W`).

評分準則

1 mark: Correctly identifying the counts for the consecutive runs of pixels (6, 4, 6).
1 mark: Expressing the full compressed representation in a valid RLE format (e.g., `6W 4B 6W` or `W6 B4 W6`).
題目 21 · structured
4
An automated greenhouse control system manages a ventilator motor \(X\). The system uses three sensors to monitor conditions:
- Temperature sensor \(A\): outputs 1 if temperature is high, 0 otherwise.
- Humidity sensor \(B\): outputs 1 if humidity is high, 0 otherwise.
- Override switch \(C\): outputs 1 if manual override is active, 0 otherwise.

The ventilator motor is activated (\(X=1\)) if:
- The manual override is active OR
- The temperature is high and the humidity is not high.

(a) Write the Boolean expression that represents this system control. [2 marks]
(b) Identify all combinations of inputs \(A, B\) and \(C\) that result in the ventilator motor being activated. Write your answer by listing the input triples in the format \((A, B, C)\). [2 marks]
查看答案詳解

解題

Part (a):
- 'The manual override is active' corresponds to \(C\).
- 'The temperature is high AND the humidity is NOT high' corresponds to \(A \cdot \overline{B}\) (or \(A \text{ AND NOT } B\)).
- 'OR' links these two conditions together, giving the Boolean expression:
\(X = C + (A \cdot \overline{B})\) or \(X = C \lor (A \land \neg B)\).

Part (b):
- If \(C = 1\), the term \(C\) is 1, so \(X = 1\). This gives four combinations: \((0, 0, 1)\), \((0, 1, 1)\), \((1, 0, 1)\), and \((1, 1, 1)\).
- If \(C = 0\), we must have \(A \cdot \overline{B} = 1\), which requires \(A = 1\) and \(B = 0\). This gives the single combination: \((1, 0, 0)\).
- Combining these, we get the 5 valid combinations: \((0, 0, 1)\), \((0, 1, 1)\), \((1, 0, 0)\), \((1, 0, 1)\), and \((1, 1, 1)\).

評分準則

Part (a) [2 Marks]:
- 1 mark for expressing \(A \cdot \overline{B}\) correctly (accept logical notation, e.g., \(A \text{ AND NOT } B\)).
- 1 mark for the correct final expression: \(X = C + (A \cdot \overline{B})\) (or equivalent).

Part (b) [2 Marks]:
- 1 mark for listing at least 3 correct combinations with no more than 1 incorrect combination.
- 2 marks for listing all 5 correct combinations: \((0, 0, 1)\), \((0, 1, 1)\), \((1, 0, 0)\), \((1, 0, 1)\), and \((1, 1, 1)\) with no extra/incorrect combinations.
題目 22 · structured
4
A manufacturing plant uses touchscreens for its control panels. The engineers are choosing between a resistive touchscreen and a capacitive touchscreen.

(a) Identify two advantages of using a resistive touchscreen over a capacitive touchscreen in a dusty, heavy-industry factory environment. [2 marks]
(b) Explain the physical mechanism of a resistive touchscreen that enables these advantages. [2 marks]
查看答案詳解

解題

Part (a):
- Resistive touchscreens rely on physical pressure rather than electrical capacitance of the finger. This means operators can wear heavy industrial gloves (which block capacitance) and still interact with the screen.
- Surface contaminants like dirt, dust, and grease do not alter the physical contact mechanism, whereas they can disrupt electrical fields on a capacitive touchscreen.

Part (b):
- The screen features two thin, conductive, resistive layers separated by a spacer gap or tiny dots.
- When a finger or stylus exerts physical pressure on the outer screen layer, it flexes and makes physical contact with the lower layer.
- This contact completes an electrical circuit, altering the voltage/resistance. Microprocessors calculate the touch coordinates based on where the resistance changed.

評分準則

Part (a) [2 Marks]:
- 1 mark for identifying that it can be operated wearing gloves / with any stylus.
- 1 mark for stating it is resistant to environmental contaminants (e.g. dust, water, grease).

Part (b) [2 Marks]:
- 1 mark for describing the construction: two conductive/resistive layers separated by a gap (or spacers).
- 1 mark for describing the action: physical pressure forces the top layer to touch the bottom layer, completing an electrical circuit/changing resistance to determine the coordinate.
題目 23 · structured
4
A logic circuit has three inputs, \(P\), \(Q\), and \(R\):
- Input \(P\) and input \(Q\) are fed into a NAND gate to produce intermediate output \(W\).
- Input \(Q\) and input \(R\) are fed into an XOR gate to produce intermediate output \(Y\).
- Outputs \(W\) and \(Y\) are then fed into a NOR gate to produce the final system output \(Z\).

(a) Write the boolean expression for the output \(Z\) in terms of inputs \(P\), \(Q\), and \(R\). [2 marks]
(b) Determine the output state of \(Z\) (0 or 1) for the following input conditions:
(i) \(P = 1\), \(Q = 1\), \(R = 1\) [1 mark]
(ii) \(P = 0\), \(Q = 1\), \(R = 0\) [1 mark]
查看答案詳解

解題

Part (a):
- The NAND gate output is \(W = \overline{P \cdot Q}\).
- The XOR gate output is \(Y = Q \oplus R\).
- The NOR gate combines them to produce \(Z = \overline{W + Y} = \overline{\overline{P \cdot Q} + (Q \oplus R)}\).

Part (b):
(i) When \(P = 1\, Q = 1\, R = 1\):
- \(W = \text{NAND}(1, 1) = 0\)
- \(Y = \text{XOR}(1, 1) = 0\)
- \(Z = \text{NOR}(0, 0) = 1\)

(ii) When \(P = 0\, Q = 1\, R = 0\):
- \(W = \text{NAND}(0, 1) = 1\)
- \(Y = \text{XOR}(1, 0) = 1\)
- \(Z = \text{NOR}(1, 1) = 0\)

評分準則

Part (a) [2 Marks]:
- 1 mark for expressing \(W = \overline{P \cdot Q}\) and \(Y = Q \oplus R\) correctly.
- 1 mark for combining \(W\) and \(Y\) with a NOR operator to get \(Z = \overline{W + Y}\) (or equivalent).

Part (b) [2 Marks]:
- 1 mark for correct output value of \(Z = 1\) for part (i).
- 1 mark for correct output value of \(Z = 0\) for part (ii).

卷二 Fundamental Problem-solving and Programming Skills

Answer all questions. Calculators must not be used.
19 題目 · 80
題目 1 · Pseudocode Operators & Evaluation
4
The following pseudocode variables are declared and initialized: X <- 19, Y <- 5, Z <- 3. Evaluate the following pseudocode expression: Ans <- (X MOD Y) * Z + 27 DIV (Y + Z - 2). State the final value assigned to Ans.
查看答案詳解

解題

Let us evaluate the expression step-by-step: 1. Evaluate the first bracketed expression: (X MOD Y) = (19 MOD 5) = 4. 2. Evaluate the second bracketed expression: (Y + Z - 2) = (5 + 3 - 2) = 6. 3. Evaluate the integer division: 27 DIV 6 = 4. 4. Evaluate the multiplication: 4 * Z = 4 * 3 = 12. 5. Evaluate the addition of the two terms: 12 + 4 = 16. Therefore, the final value assigned to Ans is 16.

評分準則

1 mark for evaluating (X MOD Y) to 4. 1 mark for evaluating the divisor expression (Y + Z - 2) to 6. 1 mark for evaluating 27 DIV 6 to 4. 1 mark for the correct final evaluated value of 16.
題目 2 · Pseudocode Operators & Evaluation
4
The following pseudocode variables are declared and initialized: Str1 <- "ALGORITHM", Str2 <- "STRUCTURES". Note that string indexing in this pseudocode starts at index 1. Evaluate the following pseudocode expression: Result <- LEFT(Str1, 2) & MID(Str2, 3, 3) & RIGHT(Str1, LENGTH(Str1) - 6). State the final string value assigned to Result.
查看答案詳解

解題

Let us evaluate each substring operation step-by-step: 1. LEFT(Str1, 2) extracts the leftmost 2 characters of 'ALGORITHM', which is 'AL'. 2. MID(Str2, 3, 3) extracts 3 characters from 'STRUCTURES' starting at index 3 (where 'S' is 1, 'T' is 2, and 'R' is 3), which results in 'RUC'. 3. LENGTH(Str1) returns 9. The expression (LENGTH(Str1) - 6) evaluates to 9 - 6 = 3. 4. RIGHT(Str1, 3) extracts the rightmost 3 characters of 'ALGORITHM', which is 'ITH'. 5. Finally, concatenating the three parts with the & operator: 'AL' & 'RUC' & 'ITH' gives the final string 'ALRUCITH'.

評分準則

1 mark for evaluating LEFT(Str1, 2) to 'AL'. 1 mark for evaluating MID(Str2, 3, 3) to 'RUC'. 1 mark for correctly evaluating the length calculation and RIGHT(Str1, 3) to 'ITH'. 1 mark for the correct final concatenated string 'ALRUCITH' (allow matching lowercase or quotes, but reject incorrect characters).
題目 3 · Pseudocode Operators & Evaluation
4
The following pseudocode variables are declared and initialized: A <- TRUE, B <- FALSE, C <- TRUE, X <- 15, Y <- 20. Evaluate the following boolean expression: Result <- (X + 5 >= Y) AND (NOT A OR B) OR (C AND (X DIV 3 = 5)). State the final boolean value assigned to Result.
查看答案詳解

解題

Let us evaluate the boolean sub-expressions step-by-step: 1. Evaluate the first relation: (X + 5 >= Y) -> (15 + 5 >= 20) -> (20 >= 20) which is TRUE. 2. Evaluate the second group: (NOT A OR B) -> (NOT TRUE OR FALSE) -> (FALSE OR FALSE) which is FALSE. 3. Combine these using AND: TRUE AND FALSE which is FALSE. 4. Evaluate the arithmetic relation: (X DIV 3 = 5) -> (15 DIV 3 = 5) -> (5 = 5) which is TRUE. 5. Evaluate the rightmost term: (C AND TRUE) -> (TRUE AND TRUE) which is TRUE. 6. Combine the left-hand side and right-hand side using OR: FALSE OR TRUE which evaluates to TRUE.

評分準則

1 mark for evaluating (X + 5 >= Y) to TRUE. 1 mark for evaluating (NOT A OR B) to FALSE. 1 mark for evaluating (C AND (X DIV 3 = 5)) to TRUE. 1 mark for evaluating the final combined expression to TRUE.
題目 4 · structured
5
An algorithm is represented by the following flowchart description:

* **Start**: Start of algorithm.
* **Step 1**: Initialize `Total ◄─ 0` and `Count ◄─ 0`.
* **Step 2**: Input a value into variable `Num`.
* **Step 3**: If `Num = 0`, then go to **Step 7**.
* **Step 4**: If `Num > 0`, then go to **Step 5**, else go to **Step 2**.
* **Step 5**: Update `Total ◄─ Total + Num`.
* **Step 6**: Update `Count ◄─ Count + 1`. Go to **Step 2**.
* **Step 7**: Calculate `Average ◄─ Total / Count`.
* **Step 8**: Output the value of `Average`.
* **End**: End of algorithm.

Complete the trace table for this algorithm using the following input dataset:
`9, 15, -3, 0`

*(Note: Write variable changes only when a value is updated. If a value does not change, leave the cell blank.)*
查看答案詳解

解題

The completed trace table is as follows:

| Num | Total | Count | Average | Output |
| :---: | :---: | :---: | :---: | :---: |
| | 0 | 0 | | |
| 9 | 9 | 1 | | |
| 15 | 24 | 2 | | |
| -3 | | | | |
| 0 | | | 12 | 12 |

### Step-by-Step Execution:
1. **Initialization**: `Total` is set to `0` and `Count` is set to `0`.
2. **First Input (`9`)**: `Num` becomes `9`. Since `Num > 0`, `Total` becomes `0 + 9 = 9` and `Count` becomes `0 + 1 = 1`.
3. **Second Input (`15`)**: `Num` becomes `15`. Since `Num > 0`, `Total` becomes `9 + 15 = 24` and `Count` becomes `1 + 1 = 2`.
4. **Third Input (`-3`)**: `Num` becomes `-3`. Since `Num` is not `0` and not `> 0`, the algorithm bypasses the accumulator steps and loops back to input. No changes to `Total` or `Count`.
5. **Fourth Input (`0`)**: `Num` becomes `0`. The decision `Num = 0` directs the algorithm to Step 7. `Average` is calculated as `24 / 2 = 12`. Finally, `12` is output.

評分準則

1 mark for correct initialization of `Total` and `Count` to `0`.
1 mark for correct tracing of first input `9` (`Total = 9`, `Count = 1`).
1 mark for correct tracing of second input `15` (`Total = 24`, `Count = 2`).
1 mark for correct handling of negative input `-3` (showing `Num = -3` with no change to `Total` or `Count`).
1 mark for correct calculation of `Average` (`12`) and correct final output (`12`).
題目 5 · short_answer
3
A programmer is writing a pseudocode function to search for a specific product ID in an existing text file named 'Inventory.txt'. Each line of the file contains a single product ID. The function 'SearchProduct' takes a target ID as a parameter, reads the file, and returns TRUE if the product is found, or FALSE otherwise.

Complete the three missing lines of pseudocode:

FUNCTION SearchProduct(TargetID : STRING) RETURNS BOOLEAN
DECLARE CurrentID : STRING
DECLARE Found : BOOLEAN
Found <- FALSE
OPENFILE "Inventory.txt" FOR READ
WHILE NOT EOF("Inventory.txt") AND Found = FALSE
[LINE A]
IF CurrentID = TargetID THEN
[LINE B]
ENDIF
ENDWHILE
[LINE C]
RETURN Found
ENDFUNCTION
查看答案詳解

解題

LINE A requires reading a line from the file into the variable CurrentID. In CAIE pseudocode, the syntax is READFILE , . Thus: READFILE "Inventory.txt", CurrentID.

LINE B updates the Boolean flag Found to TRUE once a match is identified: Found <- TRUE.

LINE C closes the file before the function terminates: CLOSEFILE "Inventory.txt".

評分準則

1 Mark: LINE A - READFILE "Inventory.txt", CurrentID (Accept minor syntax variations but must include file name and correct variable)
1 Mark: LINE B - Found <- TRUE (or Found = TRUE)
1 Mark: LINE C - CLOSEFILE "Inventory.txt"
題目 6 · short_answer
3
The following pseudocode procedure is designed to add a new error code to the end of an existing text file named 'ErrorLog.txt' without erasing its current contents.

PROCEDURE AppendError(ErrorCode : STRING)
OPENFILE "ErrorLog.txt" FOR [MODE]
WRITEFILE "ErrorLog.txt", ErrorCode
[CLOSE_STATEMENT]
ENDPROCEDURE

(a) State the correct pseudocode keyword for [MODE].
(b) State the correct pseudocode statement for [CLOSE_STATEMENT].
(c) Describe what would happen to the existing data in 'ErrorLog.txt' if the mode WRITE was used instead of [MODE].
查看答案詳解

解題

For (a), the correct mode to append data to an existing file without deleting its current contents is APPEND. WRITE mode overwrites existing data.
For (b), all opened files must be closed using CLOSEFILE .
For (c), opening a file FOR WRITE clears any existing data in the file (truncation), resulting in the loss of previous log entries.

評分準則

1 Mark: (a) APPEND
1 Mark: (b) CLOSEFILE "ErrorLog.txt"
1 Mark: (c) Explanation that WRITE mode overwrites/erases existing contents of the file.
題目 7 · short_answer
3
A text file named 'Sales.txt' contains the following three lines of data:
150
200
50

Consider the following pseudocode algorithm:

DECLARE Total : INTEGER
DECLARE Value : STRING
DECLARE Num : INTEGER
Total <- 0
OPENFILE "Sales.txt" FOR READ
WHILE NOT EOF("Sales.txt")
READFILE "Sales.txt", Value
Num <- STRING_TO_NUM(Value)
IF Num > 100 THEN
Total <- Total + Num
ENDIF
ENDWHILE
CLOSEFILE "Sales.txt"
OUTPUT Total

(a) State the output value produced when this algorithm runs.
(b) Explain why the built-in function STRING_TO_NUM is necessary in this algorithm.
查看答案詳解

解題

For (a), the loop reads each line:
- Line 1: '150' -> converted to 150. Since 150 > 100, Total becomes 0 + 150 = 150.
- Line 2: '200' -> converted to 200. Since 200 > 100, Total becomes 150 + 200 = 350.
- Line 3: '50' -> converted to 50. Since 50 is not > 100, Total remains 350.
Output is 350.

For (b), file operations read data as strings. Attempting to perform arithmetic additions or numerical comparisons directly on string data will cause a runtime type mismatch error.

評分準則

1 Mark: (a) 350
1 Mark: (b) Identifies that text file input is read as a STRING data type.
1 Mark: (b) Explains that conversion is needed to perform arithmetic operations (addition) or logical comparison (>).
題目 8 · Array & Loop Pseudocode Completion
5
An algorithm is required to process a 1D array `Scores` containing 50 integer values (indexed 1 to 50). It calculates the average of all positive scores (greater than 0) and counts how many scores are negative (less than 0). Any score that is exactly 0 is ignored.

Complete the pseudocode below by writing the missing code for **** to ****.

```pseudocode
DECLARE SumPositive : INTEGER
DECLARE CountPositive : INTEGER
DECLARE CountNegative : INTEGER
DECLARE Index : INTEGER
DECLARE AveragePositive : REAL

SumPositive <- 0
CountPositive <- 0
CountNegative <- 0

FOR Index <- 1 TO 50
IF Scores[Index] > 0 THEN
SumPositive <- SumPositive + Scores[Index]
CountPositive <-
ELSE
IF THEN
CountNegative <- CountNegative + 1
ENDIF
ENDIF
NEXT Index

IF THEN
AveragePositive <-
ELSE
AveragePositive <- 0.0
ENDIF

OUTPUT "Average positive score: ", AveragePositive
OUTPUT "Number of negative scores: ",
```
查看答案詳解

解題

Let's trace the implementation step-by-step:
1. **BLANK 1**: To count how many positive values are processed, we increment the positive counter by 1: `CountPositive + 1`.
2. **BLANK 2**: In the `ELSE` clause, the score is either negative or zero. To increment the negative count only, we check if the value is strictly less than 0: `Scores[Index] < 0`.
3. **BLANK 3**: Before executing a division, we must perform a division-by-zero validation. We check if any positive values were successfully recorded: `CountPositive > 0`.
4. **BLANK 4**: The average calculation requires dividing the accumulated positive sum by the positive count: `SumPositive / CountPositive`.
5. **BLANK 5**: Finally, we output the variable containing the negative count: `CountNegative`.

評分準則

1 mark for each correct blank:
- BLANK 1: `CountPositive + 1`
- BLANK 2: `Scores[Index] < 0`
- BLANK 3: `CountPositive > 0` (or `CountPositive >= 1` or `CountPositive <> 0`)
- BLANK 4: `SumPositive / CountPositive`
- BLANK 5: `CountNegative`
題目 9 · Array & Loop Pseudocode Completion
5
A 2D array `Sales` stores sales data as real values. It is indexed `Sales[1:12, 1:4]`, representing 12 months (rows) and 4 business branches (columns).

A programmer wants to calculate the total sales for each branch and store them in a 1D array `BranchTotals[1:4]` of real values.

Complete the pseudocode below by writing the missing code for **** to ****.

```pseudocode
DECLARE Row, Col : INTEGER

// Initialize the 1D array to 0.0
FOR Col <- 1 TO 4
BranchTotals[Col] <- 0.0
NEXT Col

// Calculate column totals
FOR Col <- 1 TO 4
FOR Row <-
BranchTotals[] <- +
Row
NEXT Col
```
查看答案詳解

解題

1. **BLANK 1**: To loop through every month for a given branch, the inner loop must cover all rows of the 2D array. This range is `1 TO 12`.
2. **BLANK 2**: The current column index is controlled by the outer loop variable `Col`. We update the running total of the current branch in `BranchTotals[Col]`.
3. **BLANK 3**: Accumulation requires adding the new value to the existing subtotal. Thus, we refer to `BranchTotals[Col]`.
4. **BLANK 4**: The individual sale cell to add is the element located at the current month (row) and current branch (column): `Sales[Row, Col]`.
5. **BLANK 5**: The inner loop starts with `FOR Row`, which must be closed using the loop closing keyword `NEXT` (or `NEXT Row`).

評分準則

1 mark for each correct blank:
- BLANK 1: `1 TO 12`
- BLANK 2: `Col`
- BLANK 3: `BranchTotals[Col]`
- BLANK 4: `Sales[Row, Col]` (or `Sales[Row][Col]`)
- BLANK 5: `NEXT` (accept `NEXT Row` or `ENDFOR` if following alternative pseudocode conventions)
題目 10 · Array & Loop Pseudocode Completion
5
An algorithm performs a linear search on a 1D array `Names` of 100 elements (indexed 1 to 100). The algorithm searches for a value stored in `Target` and terminates the iteration early once a match is successfully identified.

Complete the pseudocode below by writing the missing code for **** to ****.

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

Index <- 1
Found <- FALSE

WHILE AND DO
IF Names[Index] = Target THEN
Found <- TRUE
ELSE
Index <-
ENDIF
ENDWHILE

IF THEN
OUTPUT "Target found at index: ",
ELSE
OUTPUT "Target not found."
ENDIF
```
查看答案詳解

解題

1. **BLANK 1**: The loop should not proceed beyond the boundaries of the 100-element array. Therefore, the boundary check requires `Index <= 100`.
2. **BLANK 2**: The loop must terminate early if the target is found. This means execution continues as long as `Found` remains `FALSE` (i.e., `Found = FALSE` or `NOT Found`).
3. **BLANK 3**: If the target matches, `Found` becomes `TRUE`. If it does not match, the pointer advances to check the next element: `Index + 1`.
4. **BLANK 4**: Following loop execution, we verify if the search succeeded by checking the state of the Boolean flag: `Found = TRUE` (or simply `Found`).
5. **BLANK 5**: If the item was found, the current index is returned: `Index`.

評分準則

1 mark for each correct blank:
- BLANK 1: `Index <= 100` (accept `Index < 101` or equivalent boundary logic)
- BLANK 2: `Found = FALSE` (accept `NOT Found` or `Found <> TRUE`)
- BLANK 3: `Index + 1`
- BLANK 4: `Found = TRUE` (accept `Found` or `Found = TRUE`)
- BLANK 5: `Index`
題目 11 · short-answer
3
A systems analyst is commissioned to develop a new computerized booking system for a local theater. They are currently in the Analysis phase of the Software Development Life Cycle (SDLC). State three distinct activities that the analyst would perform during this Analysis phase.
查看答案詳解

解題

During the Analysis phase, the systems analyst must thoroughly understand the current system and what is required of the new system. The key tasks include:
1. Fact-finding/Requirements Gathering: Engaging with the client and users through methods such as questionnaires, interviews, observing current practices, or reviewing existing documentation.
2. Feasibility Study: Assessing if the project is worth pursuing by analyzing costs, technical requirements, legal issues, operational impacts, and time constraints.
3. Requirements Specification: Documenting the precise requirements (both functional and non-functional) that the new system must satisfy. This acts as a contract between the developer and the client.

評分準則

Award 1 mark for each valid activity identified, up to a maximum of 3 marks.
- Fact-finding / requirements gathering (accept specific methods like interviews, questionnaires, observation, document analysis)
- Feasibility study / producing a feasibility report
- Establishing / documenting system requirements (accept: producing a requirements specification document)
- Analyzing the current system's workflows or inputs and outputs
題目 12 · short-answer
3
A software development firm is choosing a development life cycle model for a new flight-control software project, which is safety-critical. Explain three reasons why the Waterfall model is more suitable than the Rapid Application Development (RAD) model for this specific project.
查看答案詳解

解題

For a safety-critical flight-control system, predictability, thorough verification, and formal documentation are paramount:
1. Requirements Stability: Flight-control software must have fully defined and frozen specifications from the start because changing requirements mid-development could introduce catastrophic flaws. Waterfall is ideal for fixed requirements, whereas RAD is designed for projects where requirements evolve.
2. Documentation and Certification: Aviation authorities require exhaustive, formal documentation for every phase of development to certify the software. Waterfall produces detailed specifications and design documents at each stage. RAD focuses on software prototypes, often resulting in sparse documentation.
3. Testing and Verification: Waterfall requires formal, extensive testing against the rigid requirements specification at the end of development, with strict phase gates. RAD relies on rapid, informal user-testing of prototypes, which is insufficient and dangerous for verifying complex, life-or-death autopilot algorithms.

評分準則

Award 1 mark for each valid explanation linking a Waterfall/RAD characteristic to the context of safety-critical/flight-control software, up to a maximum of 3 marks.
- 1 mark: Requirements must be stable/fully understood at the start (Waterfall) vs. changing requirements (RAD).
- 1 mark: Strict documentation/regulatory compliance is required for certification (Waterfall) vs. informal prototyping/less documentation (RAD).
- 1 mark: Rigorous, structured phase-by-phase verification/testing is needed to prevent catastrophic failures (Waterfall) vs. rapid, feedback-driven iterations (RAD).
題目 13 · practical
7
A software developer is writing a program to standardise user-entered promotional codes.

Write pseudocode for the function `CleanAndFormat` which takes a string parameter `InputStr` and returns a formatted string.

The function must perform the following steps:
1. Iterate through `InputStr` and extract only alphanumeric characters (lowercase letters 'a' to 'z', uppercase letters 'A' to 'Z', and digits '0' to '9'). All other characters (such as spaces, punctuation, or symbols) must be ignored.
2. Convert all extracted alphabetic characters to lowercase.
3. Adjust the resulting string so that it is exactly 10 characters long:
- If the string length is greater than 10, truncate it to keep only the first 10 characters.
- If the string length is less than 10, pad the string by appending asterisk characters (`"*"`) to the end until its length is exactly 10.
- If the string length is already exactly 10, no adjustment is needed.
4. Return the final 10-character string.

You should assume the existence of standard pseudocode string functions such as `LENGTH(str)`, `MID(str, start, length)`, `LEFT(str, length)`, and `LCASE(char)`.
查看答案詳解

解題

To solve this problem, we build a new string (`ResultStr`) by iterating through each character of the input string (`InputStr`).

1. We initialize an empty string `ResultStr` and loop from index 1 to `LENGTH(InputStr)`.
2. In each iteration, we extract a single character using `MID(InputStr, i, 1)`.
3. We check if the character is alphanumeric by comparing it against character ranges: `'a'` to `'z'`, `'A'` to `'Z'`, and `'0'` to `'9'`.
4. If it matches, we convert it to lowercase using `LCASE()` and concatenate it to `ResultStr` using the `&` operator.
5. After the loop, we check the length of `ResultStr`:
- If `LENGTH(ResultStr) > 10`, we truncate it using `LEFT(ResultStr, 10)`.
- If `LENGTH(ResultStr) < 10`, we use a loop to append the `"*"` character until the length reaches 10.
6. Finally, we return `ResultStr` and close the function definition with `ENDFUNCTION`.

評分準則

Award marks as follows (Max 7 marks):
- 1 mark: Correct `FUNCTION` header (declaring parameter `InputStr : STRING` and returning `STRING`) and corresponding `ENDFUNCTION`.
- 1 mark: Correct loop from 1 to `LENGTH(InputStr)` to examine each character of the input string.
- 1 mark: Correct use of `MID` (or equivalent) to isolate each individual character.
- 1 mark: Correct conditional statement to check if a character is alphanumeric (checks uppercase letters, lowercase letters, and digits).
- 1 mark: Correct conversion of characters to lowercase (using `LCASE` or equivalent) and concatenation to accumulate the valid characters.
- 1 mark: Correct condition and logic to truncate the string to 10 characters using `LEFT` if its length exceeds 10.
- 1 mark: Correct condition and loop/logic to pad the string with `"*"` characters if its length is less than 10, and a final `RETURN` statement.
題目 14 · written-response
3
A structure chart contains a module named CalculateTax. The module receives two parameters from its calling module: GrossSalary (a numeric value with a fractional part) and TaxCode (a text value). The module calculates and returns a single value, the net tax (a numeric value with a fractional part), back to the calling module. Write the pseudocode module header for CalculateTax using the standard Cambridge 9618 pseudocode style.
查看答案詳解

解題

1. Identify the module type: Since the module returns a single value back to the calling module, it must be declared as a FUNCTION. 2. Identify the parameters: The module receives GrossSalary which can have fractional parts (type REAL) and TaxCode which is a text value (type STRING). 3. Identify the return type: The function returns net tax which can also have fractional parts (type REAL). 4. Combine these into the standard 9618 header format: FUNCTION CalculateTax(GrossSalary : REAL, TaxCode : STRING) RETURNS REAL

評分準則

1 mark: Correct keyword FUNCTION and identifier CalculateTax. 1 mark: Correct parameters (GrossSalary and TaxCode) with their correct data types (REAL and STRING). 1 mark: Correct return data type (RETURNS REAL).
題目 15 · written-response
3
A structure chart shows a module Main calling a module named GetMemberDetails. The module GetMemberDetails does not receive any input values from Main, but it returns two values back to Main: StudentID (a text value consisting of alphanumeric characters) and IsActive (a boolean status). Write the pseudocode module header for GetMemberDetails using the standard Cambridge 9618 pseudocode style.
查看答案詳解

解題

1. Identify the module type: Because the module returns more than one value to the calling environment (StudentID and IsActive), it cannot be a standard function. It must be declared as a PROCEDURE. 2. Define how values are returned: Since a procedure does not have a RETURN statement, it must return values to the calling module via reference parameters. Therefore, we use the BYREF keyword for both parameters. 3. Identify the data types: StudentID is a text value (type STRING) and IsActive is a boolean status (type BOOLEAN). 4. Combine into standard 9618 header format: PROCEDURE GetMemberDetails(BYREF StudentID : STRING, BYREF IsActive : BOOLEAN)

評分準則

1 mark: Correct keyword PROCEDURE and identifier GetMemberDetails. 1 mark: Use of BYREF for both parameters to indicate they are passed by reference to return values. 1 mark: Correct parameter names and data types (StudentID : STRING and IsActive : BOOLEAN).
題目 16 · Record Structure Array Pseudocode Writing
5
A programmer is developing a system for a school library. Write pseudocode to define a record type Book with the following fields:
- Title (STRING)
- Author (STRING)
- Year (INTEGER)

Then, write pseudocode to declare a 1D array named Library of 100 elements of type Book (indexed 1 to 100) and initialize the Year field of all 100 elements in the array to 0.
查看答案詳解

解題

The solution requires three steps:
1. Define the user-defined record type using TYPE ... ENDTYPE syntax, declaring each field with its appropriate type.
2. Declare the 1D array of 100 Book records with proper bounds (1 to 100).
3. Use a FOR loop to iterate through every index of the array, accessing the Year field of each record using dot notation (.) and assigning it the value 0.

Example Pseudocode:
TYPE Book
DECLARE Title : STRING
DECLARE Author : STRING
DECLARE Year : INTEGER
ENDTYPE

DECLARE Library : ARRAY[1:100] OF Book
DECLARE Index : INTEGER
FOR Index <- 1 TO 100
Library[Index].Year <- 0
NEXT Index

評分準則

1 mark: Correct TYPE Book ... ENDTYPE structure with all fields (Title, Author, Year) defined with correct data types.
1 mark: Correct declaration of Library array of 100 Book records (e.g. ARRAY[1:100] OF Book).
1 mark: Loop correctly set up to iterate 100 times (1 to 100 or 0 to 99).
1 mark: Correctly accesses the Year field of each array element using dot notation (Library[Index].Year).
1 mark: Assigns 0 to the accessed field inside the loop and includes correct variable declarations (e.g., Index).
題目 17 · Record Structure Array Pseudocode Writing
5
An educational software program uses a record type Student defined as follows:

TYPE Student
DECLARE StudentID : STRING
DECLARE Name : STRING
DECLARE TestScore : INTEGER
ENDTYPE

An array Classroom of 30 Student records (indexed 1 to 30) is declared and populated with data. Write a pseudocode function GetAverage that takes the Classroom array as a parameter and returns the average test score of the class as a REAL value.
查看答案詳解

解題

The function must iterate through the 30 indices of the passed 'Classroom' array, sum the 'TestScore' field from each record, and divide the sum by 30 to calculate and return the average.

Full solution:
FUNCTION GetAverage(Classroom : ARRAY OF Student) RETURNS REAL
DECLARE Total : INTEGER
DECLARE Index : INTEGER
Total <- 0
FOR Index <- 1 TO 30
Total <- Total + Classroom[Index].TestScore
NEXT Index
RETURN Total / 30.0
ENDFUNCTION

評分準則

1 mark: Correct function header with parameter (array of Student) and return type REAL.
1 mark: Initialize accumulator variable (e.g., Total <- 0) and declare variables.
1 mark: Set up loop to iterate 30 times (1 to 30).
1 mark: Accumulate scores using record field notation correctly (e.g., Classroom[Index].TestScore).
1 mark: Divide accumulated total by 30.0, use RETURN to output average, and end with ENDFUNCTION.
題目 18 · Record Structure Array Pseudocode Writing
5
A retail store management system uses a record type Product with fields ProductCode (STRING), Price (REAL), and StockLevel (INTEGER). A global array Inventory contains 50 elements of type Product (indexed 1 to 50). Write a pseudocode procedure UpdateStock that takes two parameters: a product code string SearchCode and an integer Quantity. The procedure must search the Inventory array for a product with a matching ProductCode. If found, the procedure must update its StockLevel field by adding the Quantity value (which can be positive or negative) and terminate. If the code is not found, no change should be made.
查看答案詳解

解題

The procedure performs a linear search. It checks each ProductCode in the global Inventory array. When a match is found, it adds the Quantity parameter to the existing StockLevel and sets a flag or terminates the loop to avoid unnecessary iterations.

Full solution:
PROCEDURE UpdateStock(SearchCode : STRING, Quantity : INTEGER)
DECLARE Index : INTEGER
DECLARE Found : BOOLEAN
Found <- FALSE
Index <- 1
WHILE Index <= 50 AND Found = FALSE
IF Inventory[Index].ProductCode = SearchCode THEN
Inventory[Index].StockLevel <- Inventory[Index].StockLevel + Quantity
Found <- TRUE
ELSE
Index <- Index + 1
ENDIF
ENDWHILE
ENDPROCEDURE

評分準則

1 mark: Correct procedure header taking SearchCode and Quantity parameters with correct data types.
1 mark: Set up a search loop (using WHILE/REPEAT or FOR with exit check) to iterate through the array.
1 mark: Correctly compare the array field (Inventory[Index].ProductCode) to SearchCode.
1 mark: Correctly update StockLevel field by adding Quantity (e.g. Inventory[Index].StockLevel <- Inventory[Index].StockLevel + Quantity).
1 mark: Proper implementation of loop termination once found and correct use of ENDPROCEDURE.
題目 19 · Record Structure Array Pseudocode Writing
5
An athletics club track system uses a record structure defined as follows:

TYPE Athlete
DECLARE Name : STRING
DECLARE Country : STRING
DECLARE PersonalBest : REAL
ENDTYPE

A global array RunningTeam contains 20 elements of type Athlete (indexed 1 to 20). Write a pseudocode procedure DisplayBest that finds and displays the Name and Country of the athlete with the lowest PersonalBest time (representing the fastest runner). Assume all PersonalBest values are unique and positive.
查看答案詳解

解題

The procedure identifies the record with the minimum PersonalBest time by initializing a minimum tracker to the first athlete's personal best, iterating through the remaining records, updating the tracker and index when a lower time is found, and finally outputting the name and country of the runner at that best index.

Full solution:
PROCEDURE DisplayBest()
DECLARE MinTime : REAL
DECLARE BestIndex : INTEGER
DECLARE Index : INTEGER
MinTime <- RunningTeam[1].PersonalBest
BestIndex <- 1
FOR Index <- 2 TO 20
IF RunningTeam[Index].PersonalBest < MinTime THEN
MinTime <- RunningTeam[Index].PersonalBest
BestIndex <- Index
ENDIF
NEXT Index
OUTPUT RunningTeam[BestIndex].Name, RunningTeam[BestIndex].Country
ENDPROCEDURE

評分準則

1 mark: Correct procedure header (PROCEDURE DisplayBest()) and ENDPROCEDURE.
1 mark: Initialise tracker variables (e.g. MinTime and/or BestIndex) using the first array element.
1 mark: Set up loop to iterate through the rest of the array elements (2 to 20).
1 mark: Compare each element's PersonalBest to current minimum, correctly updating trackers if a lower value is found.
1 mark: Correctly output both the Name and Country fields of the matching record after the loop.

想知道自己有幾分把握?

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

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

免費開始練習