Cambridge IGCSE · Thinka 原創模擬試題

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

Thinka Jun 2025 (V3) Cambridge International A Level-Style Mock — Computer Science (0478)

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

卷一 Theory (Computer Systems)

Answer all questions. Calculators must not be used. Total marks: 75.
31 題目 · 65.79999999999998
題目 1 · Recall and Short Answer
1.5
Convert the 8-bit binary number 11011011 into hexadecimal. Show your steps.
查看答案詳解

解題

1. Split the 8-bit binary number into two 4-bit nibbles: 1101 and 1011.
2. Convert 1101 to decimal: \(1\times8 + 1\times4 + 0\times2 + 1\times1 = 13\), which is D in hexadecimal.
3. Convert 1011 to decimal: \(1\times8 + 0\times4 + 1\times2 + 1\times1 = 11\), which is B in hexadecimal.
4. Combine the two nibbles to get the hexadecimal value: DB.

評分準則

0.5 marks: Correctly splitting the binary byte into two nibbles (1101 and 1011).
0.5 marks: Correctly converting 1101 to D.
0.5 marks: Correctly converting 1011 to B.
題目 2 · Recall and Short Answer
1.5
Describe the function of the Interrupt Service Routine (ISR) when an interrupt occurs.
查看答案詳解

解題

When an interrupt signal is received, the CPU suspends its current execution. The Interrupt Service Routine (ISR) handles this by: 1. Saving the current state of the CPU registers (onto the stack). 2. Running the specified program code that handles the specific hardware or software event. 3. Restoring the saved CPU registers so the CPU can resume executing the original task.

評分準則

0.5 marks: Stating that the ISR saves the current state/registers of the active program.
0.5 marks: Stating that it executes the program code associated with the specific interrupt.
0.5 marks: Stating that it restores the saved state to resume the suspended task.
題目 3 · Recall and Short Answer
1.5
Explain how a checksum is calculated and compared to detect errors during data transmission.
查看答案詳解

解題

Before data is sent, the sender calculates a numerical checksum value based on the bytes of the block. This checksum is sent alongside the payload. The receiving computer recalculates the checksum from the received data using the identical algorithm. If the calculated checksum matches the received checksum, the data is assumed error-free; if they differ, a transmission error is flagged.

評分準則

0.5 marks: Mentioning the checksum is calculated prior to transmission and sent with the data.
0.5 marks: Mentioning the receiving computer recalculates the checksum upon arrival.
0.5 marks: Explaining that comparing both checksums and finding a discrepancy flags a transmission error.
題目 4 · Recall and Short Answer
1.5
State the purpose of a Uniform Resource Locator (URL) and identify one of its main components.
查看答案詳解

解題

A Uniform Resource Locator (URL) acts as an easy-to-read web address used to locate resources (like web pages or images) on the internet. Its three primary components are: 1. Protocol (e.g., http, https), 2. Domain name / host name (e.g., www.example.com), and 3. Path / file name (e.g., /about/team.html).

評分準則

0.5 marks: Stating the purpose (providing a readable web address to locate resources).
1.0 mark: Correctly identifying one main component (e.g., Protocol, Domain name / Host, or Path / File name).
題目 5 · Recall and Short Answer
1.5
State the role of the Program Counter (PC) register in the von Neumann CPU architecture.
查看答案詳解

解題

The Program Counter (PC) is a dedicated register inside the Control Unit of the CPU. It holds the memory address of the next instruction scheduled for execution. Once the current instruction address is fetched and sent to the Memory Address Register (MAR), the PC is automatically incremented by 1 to point to the next instruction in sequence.

評分準則

1.0 mark: Clearly stating it holds the memory address of the next instruction to be fetched.
0.5 marks: Stating that it is incremented during the Fetch cycle to point to the subsequent instruction.
題目 6 · Recall and Short Answer
1.5
State one typical application of a 3D scanner, and explain how a 3D scanner differs in functionality from a 2D scanner.
查看答案詳解

解題

A 3D scanner is commonly used in medical prosthetics (to scan body parts), reverse engineering, or creating digital CAD models of physical objects for 3D printing. It differs from a 2D scanner because a 3D scanner measures the 3D dimensions (including depth/z-axis coordinates) of physical objects in space, whereas a 2D scanner only captures a flat image of a document or two-dimensional surface.

評分準則

0.5 marks: Providing a valid 3D scanner application (e.g., 3D printing, medical prosthetics, CAD design, CGI).
1.0 mark: Explaining the functional difference (3D scanner captures physical depth/volume/z-dimension of physical objects, while 2D scanner scans only flat surfaces in x and y coordinates).
題目 7 · Recall and Short Answer
1.5
Explain the main differences in how lossy and lossless compression methods reduce file size.
查看答案詳解

解題

Lossy compression achieves smaller file sizes by permanently identifying and removing redundant or less perceptible details (e.g., background noise in audio or minute color shades in photos), making exact reconstruction impossible. Lossless compression reduces file size using encoding algorithms (such as Run-Length Encoding) that group repeating sequences without discarding any data, enabling the original file to be reconstructed precisely bit-for-bit.

評分準則

0.5 marks: Explaining that lossy compression permanently deletes non-critical data.
0.5 marks: Explaining that lossless compression allows complete, exact reconstruction of the original file.
0.5 marks: Explaining that lossless compression achieves its reduction by finding and encoding redundant patterns instead of deleting data.
題目 8 · Recall and Short Answer
1.5
Define phishing and describe one method a recipient can use to identify a phishing email.
查看答案詳解

解題

Phishing is a social engineering attack where a user is sent a fake email that mimics a legitimate organization to trick them into sharing sensitive details like credentials or banking details. A user can identify a phishing email by checking the sender's actual email address for typos or unofficial domain names, checking for spelling and grammar errors, or hovering over embedded hyperlinks to verify the target URL matches the claimed sender's official website.

評分準則

0.5 marks: Correctly defining phishing (fraudulent/impersonated email sent to steal personal data).
1.0 mark: Describing a valid identification method (e.g., inspecting the sender's email domain address, looking for grammatical errors/urgent tones, or hovering over links to verify destinations).
題目 9 · Recall and Short Answer
1.5
State three typical uses of hexadecimal representation in computer systems.
查看答案詳解

解題

Hexadecimal is used in computer science for: 1. MAC addresses (e.g., media access control). 2. HTML/CSS color codes (e.g., #FF5733). 3. Memory dumps/debugging (displays memory contents in a manageable format). 4. IPv6 addresses. 5. Displaying assembly/machine code instructions.

評分準則

Award 0.5 marks for each correct use, up to a maximum of 1.5 marks. Acceptable uses: MAC addresses, HTML/CSS hex color codes, IP addresses (IPv6), memory dumps, debugging codes, or assembly language instructions.
題目 10 · Recall and Short Answer
1.5
Explain how a checksum is used to detect transmission errors.
查看答案詳解

解題

Before transmission, an algorithm is applied to the data block to calculate a checksum value. This value is transmitted along with the data. Upon receipt, the receiving system applies the same algorithm to the received data and compares its calculated checksum with the received checksum. If they differ, an error has occurred.

評分準則

Award 0.5 marks for each point up to 1.5 marks:
- Calculation of checksum prior to transmission using a specific algorithm (0.5)
- Transmission of the checksum with the data block (0.5)
- Recalculation and comparison at the receiver side to check for discrepancies (0.5)
題目 11 · Recall and Short Answer
1.5
Identify three system buses used in the Von Neumann architecture and state whether each is unidirectional or bidirectional.
查看答案詳解

解題

In the Von Neumann architecture, three system buses are: 1. Data bus: Bidirectional (transports data to/from CPU). 2. Address bus: Unidirectional (transports addresses from CPU to memory). 3. Control bus: Bidirectional/Unidirectional (carries signals/commands between CPU and other components).

評分準則

Award 0.5 marks for each correct bus identified with its correct direction:
- Data bus: Bidirectional (0.5)
- Address bus: Unidirectional (0.5)
- Control bus: Bidirectional/Unidirectional (0.5)
題目 12 · Recall and Short Answer
1.5
In an automated greenhouse system, explain the function of an actuator and state two examples of actuators that might be used.
查看答案詳解

解題

An actuator is a mechanical component controlled by a microprocessor to produce physical movement or control a system mechanism. In an automated greenhouse, it executes physical actions to adjust the environment. Examples include a motor (to open or close ventilation windows) and a solenoid valve/pump (to activate watering systems).

評分準則

Award 0.5 marks for explanation of function and 0.5 marks for each correct example:
- Actuator function: physical response/movement controlled by computer signal (0.5)
- Example 1: motor for windows/vents OR heater (0.5)
- Example 2: water pump/sprinkler valve OR light switch (0.5)
題目 13 · Recall and Short Answer
1.5
Define 'phishing' and state two ways a user could identify a phishing email.
查看答案詳解

解題

Phishing is an attempt to acquire sensitive personal information (such as usernames, passwords, or financial details) by masquerading as a trustworthy entity in electronic communications. Users can identify it by: 1. Looking at the sender's email address (often slight misspellings of real domains). 2. Observing poor spelling and grammar. 3. Checking for generic greetings like 'Dear Customer'. 4. Identifying hyperlinked URLs that do not match the destination text.

評分準則

Award 0.5 marks for the definition and 0.5 marks for each identification method (max 1.5):
- Definition: Fraudulent message attempting to trick the user into revealing sensitive data (0.5)
- Identification 1: Generic greetings / spelling and grammar errors / urgent threat tone (0.5)
- Identification 2: Mismatched sender address / suspicious URLs (0.5)
題目 14 · Recall and Short Answer
1.5
State three differences between a compiler and an interpreter.
查看答案詳解

解題

1. A compiler translates the entire high-level program into machine code at once, whereas an interpreter translates and executes line-by-line.
2. A compiler generates a standalone executable file (e.g., .exe), while an interpreter does not produce any object code file.
3. A compiler reports all errors at the end of compilation, whereas an interpreter halts execution at the very first line containing an error.

評分準則

Award 0.5 marks for each distinct difference up to a maximum of 1.5:
- Translation method (entire code vs line-by-line) (0.5)
- Output (independent executable file produced vs no executable/object code saved) (0.5)
- Error reporting (all errors listed at the end vs execution stops immediately on first error) (0.5)
題目 15 · Recall and Short Answer
1.5
Write the logic proposition that represents this logic gate setup: An AND gate has two inputs, \(A\) and \(B\). The output of this AND gate, along with a third input \(C\), are fed into a NOR gate to produce the final output \(X\).
查看答案詳解

解題

First, the inputs \(A\) and \(B\) go into an AND gate, giving \(A \text{ AND } B\).
Next, this result and input \(C\) are passed to a NOR gate. A NOR gate is equivalent to \(\text{NOT}(\dots \text{OR } \dots)\).
Therefore, the expression is: \(X = \text{NOT } ((A \text{ AND } B) \text{ OR } C)\) or \(X = (A \text{ AND } B) \text{ NOR } C\).

評分準則

Award marks as follows (total 1.5):
- Correctly showing \(A \text{ AND } B\) (0.5)
- Correctly combining with \(C\) using OR and NOT (or NOR) (0.5)
- Correct overall syntax including matching parentheses and the output \(X = \dots\) (0.5)
題目 16 · Recall and Short Answer
1.5
Distinguish between the Internet and the World Wide Web (WWW) by describing what each represents.
查看答案詳解

解題

The Internet is the physical network infrastructure comprising routers, cables, satellites, and computer systems globally connected. The World Wide Web (WWW) is an information space of documents and web resources, accessed using browsers over the Internet via protocols like HTTP/HTTPS.

評分準則

Award marks as follows (total 1.5):
- Description of Internet as the physical network infrastructure (0.5)
- Description of World Wide Web as the collection of information/pages (0.5)
- Explanation of relationship (e.g., WWW runs on top of the Internet infrastructure) (0.5)
題目 17 · short_answer
1.5
A check digit is a method of error detection. State three different types of data entry errors that a check digit can detect.
查看答案詳解

解題

A check digit is an additional digit calculated from the other digits in a number, such as an ISBN or barcode, and is used to identify data entry or transmission errors. A check digit can detect: 1. Transposition errors (where two adjacent digits are swapped, e.g., typing 45 instead of 54). 2. Single digit substitution errors (where one digit is typed incorrectly, e.g., typing 7 instead of 1). 3. Omission or addition errors (where a digit is left out or an extra digit is inserted, changing the length of the string).

評分準則

Award 0.5 marks for each distinct, valid type of error identified, up to a maximum of 1.5 marks: - Transposition of digits / swapped digits (0.5 marks) - Incorrectly entered / mistyped / substituted digit (0.5 marks) - Omitted / missing digit (0.5 marks) - Added / extra digit (0.5 marks) - Phonetic errors (e.g. typing 13 instead of 30) (0.5 marks)
題目 18 · short_answer
1.5
Explain three functions of web cookies in relation to a user's experience on an e-commerce website.
查看答案詳解

解題

Web cookies are small text files downloaded onto a user's computer by a website via the browser. For an e-commerce website, cookies perform essential tracking and personalization functions: 1. Maintaining the shopping basket state (remembering items added to the cart). 2. Session tracking / login authentication (so the user doesn't have to log in on every single page). 3. Customizing preferences (such as saving currency or language choices for future visits).

評分準則

Award 0.5 marks for each valid function explained, up to a maximum of 1.5 marks: - Keeping track of items in the shopping cart (0.5 marks) - Keeping user logged in / maintaining session state (0.5 marks) - Remembering user preferences like currency, layout, or language (0.5 marks) - Tracking browsing history to recommend personalized products or targeted ads (0.5 marks)
題目 19 · Conversions and Calculations
1.8
Add the 8-bit binary numbers \(01011100\) and \(00101011\). Convert the final sum into hexadecimal. State only the hexadecimal value in your final answer.
查看答案詳解

解題

First, add the two binary numbers: \(01011100_2 + 00101011_2 = 10000111_2\). Next, convert the 8-bit binary result to hexadecimal by splitting it into two 4-bit nibbles: The left nibble is \(1000_2\), which is \(8_{16}\). The right nibble is \(0111_2\), which is \(7_{16}\). Combining them gives \(87\).

評分準則

1 mark for showing correct binary addition resulting in \(10000111_2\). 0.8 marks for converting the binary sum correctly to the hexadecimal value \(87\).
題目 20 · Conversions and Calculations
1.8
A mono audio recording has a sample rate of \(8,000\text{ Hz}\) and a sample resolution of \(16\text{ bits}\). Calculate the file size of a \(10\text{-second}\) recording in kilobytes (KB). Assume \(1\text{ KB} = 1,000\text{ bytes}\). State only the numerical value in your final answer.
查看答案詳解

解題

First, calculate the total size in bits: \(\text{Sample rate} \times \text{Sample resolution} \times \text{Time} \times \text{Channels} = 8,000 \times 16 \times 10 \times 1 = 1,280,000\text{ bits}\). Next, convert bits to bytes by dividing by 8: \(1,280,000 / 8 = 160,000\text{ bytes}\). Finally, convert bytes to kilobytes (KB) by dividing by 1,000: \(160,000 / 1,000 = 160\text{ KB}\).

評分準則

1 mark for calculating total size in bytes (\(160,000\text{ bytes}\) or showing the working for bits). 0.8 marks for dividing by 1,000 correctly to get the final answer of \(160\).
題目 21 · Conversions and Calculations
1.8
Convert the hexadecimal number \(\text{D9}\) into denary. State only the numerical value in your final answer.
查看答案詳解

解題

Identify the place values of the two hexadecimal digits: the left digit is in the \(16\text{s}\) place and the right digit is in the \(1\text{s}\) place. Convert the hex character \(\text{D}\) to its denary value, which is \(13\). Perform the calculation: \((13 \times 16) + (9 \times 1) = 208 + 9 = 217\).

評分準則

1 mark for showing the correct working: converting \(\text{D}\) to 13 and calculating \((13 \times 16) + 9\). 0.8 marks for the correct final denary answer of \(217\).
題目 22 · Conversions and Calculations
1.8
An image has dimensions of \(512 \times 512\text{ pixels}\) and a colour depth of \(24\text{ bits}\). Calculate the file size of this image in kibibytes (KiB). Assume \(1\text{ KiB} = 1,024\text{ bytes}\). State only the numerical value in your final answer.
查看答案詳解

解題

First, calculate the total number of pixels in the image: \(512 \times 512 = 262,144\text{ pixels}\). Next, determine the file size in bytes by multiplying by the colour depth (since \(24\text{ bits} = 3\text{ bytes}\)): \(262,144 \times 3 = 786,432\text{ bytes}\). Finally, convert bytes to kibibytes (KiB) by dividing by 1,024: \(786,432 / 1,024 = 768\text{ KiB}\).

評分準則

1 mark for calculating the total file size in bytes (\(786,432\text{ bytes}\) or showing appropriate step of \(262,144 \times 3\)). 0.8 marks for converting to KiB correctly to get the final answer of \(768\).
題目 23 · Conversions and Calculations
1.8
Perform a logical shift of two places to the right on the 8-bit binary pattern \(01101000\). Convert the resulting binary pattern into denary. State only the numerical value in your final answer.
查看答案詳解

解題

Perform a logical shift of two places to the right on the binary pattern \(01101000_2\). Shifting right by two places moves all bits two positions to the right and fills the empty left-hand positions with zeros, resulting in \(00011010_2\). Convert this new binary pattern to denary: \(16 + 8 + 2 = 26\).

評分準則

1 mark for demonstrating the correct logical shift to get the binary pattern \(00011010\). 0.8 marks for converting the shifted pattern to the correct denary value of \(26\).
題目 24 · Technical Explanations
2.8
A data packet is transmitted across a network. Explain how a checksum is used to detect whether any data corruption occurred during transmission.
查看答案詳解

解題

A checksum is a mathematical value calculated from block data. The sender computes it before transmission and includes it with the packet. The receiver performs the same calculation on receipt. If the computed checksum does not match the received checksum, the data has been corrupted.

評分準則

Max 3 marks (awarded as 2.8): 1 mark for explaining that the sender calculates the checksum from data using an algorithm. 1 mark for stating that the checksum is appended and transmitted. 1 mark for explaining that the receiver recalculates and compares it, identifying an error if they do not match.
題目 25 · Technical Explanations
2.8
During the fetch stage of the fetch-decode-execute cycle, both the Program Counter (PC) and the Memory Address Register (MAR) are used. Explain the distinct roles of these two registers and how they interact during the fetch stage.
查看答案詳解

解題

The PC and MAR work together during fetch. The PC is responsible for keeping track of the next instruction's address. To fetch this instruction, the address must be moved to the MAR, which directly connects to the address bus to reference the memory location in RAM. The PC can then be updated to the next instruction address.

評分準則

Max 3 marks (awarded as 2.8): 1 mark for explaining that the PC holds the address of the next instruction. 1 mark for stating that the address is copied from the PC to the MAR. 1 mark for stating that the MAR holds the address while memory is accessed, or that the PC is incremented.
題目 26 · Technical Explanations
2.8
Audio can be stored in different formats. Explain how Musical Instrument Digital Interface (MIDI) represents sound and why its file size is significantly smaller than an MP3 file.
查看答案詳解

解題

Unlike MP3 which stores compressed digital recordings of actual sound, MIDI is a protocol that stores instructions on how to play music. It acts like sheet music, recording parameters such as velocity, pitch, and duration. A synthesizer then interprets these commands to generate sound, requiring far less data storage than MP3.

評分準則

Max 3 marks (awarded as 2.8): 1 mark for stating that MIDI stores commands/instructions rather than physical audio waves. 1 mark for explaining that MIDI files require a synthesizer or sound card to interpret commands to generate sound. 1 mark for explaining that MP3 stores actual sampled/recorded audio waves, which involves massive amounts of data compared to text-like MIDI commands.
題目 27 · Technical Explanations
2.8
Solid-state drives (SSDs) are increasingly used instead of hard disk drives. Explain how data is stored and written in NAND flash memory, including the role of floating gate transistors.
查看答案詳解

解題

NAND flash memory uses floating gate transistors to store electrical charge. When write voltage is applied, electrons are trapped inside the floating gate. The state of charge determines whether a cell represents a 1 or a 0. Since electrons remain trapped without power, memory is non-volatile.

評分準則

Max 3 marks (awarded as 2.8): 1 mark for mentioning the use of floating gate transistors or cells. 1 mark for explaining that electrons are trapped or released using voltage. 1 mark for explaining that the presence/absence of trapped electrons represents binary states (1 and 0), which remain persistent without power.
題目 28 · Technical Explanations
2.8
When a user enters a URL into a web browser, the browser retrieves and displays the webpage. Explain the role of the web browser in this process, including its interaction with the DNS and how it processes the retrieved files.
查看答案詳解

解題

A browser serves as the interface and renderer for web content. It resolves URLs into IP addresses using a DNS, initiates the HTTP/HTTPS connection with the web server, downloads the markup/style files, and compiles them to produce a visual page.

評分準則

Max 3 marks (awarded as 2.8): 1 mark for explaining that the browser sends the URL to a DNS server to retrieve the web server's IP address. 1 mark for explaining that the browser sends an HTTP/HTTPS request to download files from the web server. 1 mark for explaining that the browser renders/interprets HTML, CSS, and JS files into a readable web page.
題目 29 · Technical Explanations
2.8
An interrupt is a signal sent to the processor. Explain the purpose of an interrupt in a computer system and how the processor handles it when one is received during the execution of a program.
查看答案詳解

解題

Interrupts allow multi-tasking and prompt response to hardware/software needs. Upon receiving an interrupt, the processor pauses current tasks, stores register states, executes the corresponding interrupt service routine (ISR), and then resumes the main task.

評分準則

Max 3 marks (awarded as 2.8): 1 mark for explaining that interrupts notify the CPU of urgent events or input/output tasks requiring immediate action. 1 mark for explaining that the processor suspends the current task and saves its register states. 1 mark for explaining that the processor runs an Interrupt Service Routine (ISR) and then restores/resumes the original task.
題目 30 · Diagramming & Flow mapping
6.5
During the Fetch stage of the Fetch-Decode-Execute cycle, several steps are performed in a specific sequence to retrieve an instruction from primary memory.

(a) Below are five steps of the Fetch stage. Map these steps into their correct sequential order from 1 to 5:
- A: The instruction stored at the address in the MAR is copied to the MDR.
- B: The program counter (PC) is incremented by 1.
- C: The address of the next instruction is copied from the Program Counter (PC) to the Memory Address Register (MAR).
- D: The instruction is copied from the Memory Data Register (MDR) to the Current Instruction Register (CIR).
- E: A 'read' signal is sent along the control bus to memory.

Write the correct order of letters (from Step 1 to Step 5).

(b) System buses are used to transmit data, addresses, and control signals.
Identify the system bus used to carry the address from the MAR to the main memory, and state whether this bus is unidirectional or bidirectional.
查看答案詳解

解題

a) The Fetch stage begins with copying the address of the next instruction from the Program Counter (PC) to the Memory Address Register (MAR) [Step 1: C]. The PC is then incremented by 1 to point to the subsequent instruction [Step 2: B]. To retrieve the instruction, a 'read' signal is sent along the control bus to memory [Step 3: E]. The memory responds by copying the contents at that address to the Memory Data Register (MDR) [Step 4: A]. Finally, the instruction is copied from the MDR to the Current Instruction Register (CIR) [Step 5: D]. Note: Steps 2 and 3 can occur in either order.

b) The Address Bus carries memory addresses from the CPU to RAM and is unidirectional.

評分準則

a) [Max 5 marks]
Award 1 mark for each correctly placed step in the sequence:
- Step 1 = C
- Step 2 = B (accept E)
- Step 3 = E (accept B)
- Step 4 = A
- Step 5 = D

b) [Max 1.5 marks]
- 1 mark for identifying the 'Address Bus'
- 0.5 marks for identifying it as 'Unidirectional'
題目 31 · Diagramming & Flow mapping
6.5
A user types a URL (such as https://www.example.com) into their web browser. This initiates a sequence of events to request, locate, and retrieve the webpage.

(a) The flow of retrieving a webpage involves several steps. Map the following steps (A to F) into the correct chronological order from 1 to 6:
- A: The web browser sends an HTTP/HTTPS request directly to the IP address of the web server.
- B: The DNS server searches for the domain name in its database to find its corresponding IP address.
- C: The user enters the URL of the webpage into the address bar of the web browser.
- D: The web server processes the request and sends the webpage files (HTML, CSS, images) back to the browser.
- E: The DNS server returns the IP address of the web server to the web browser.
- F: The web browser sends a request to a Domain Name System (DNS) server to lookup the IP address of the URL.

Write the correct order of letters (from Step 1 to Step 6).

(b) To transmit the webpage files from the web server to the user's computer, the data is split into packets.
(i) Identify the TCP/IP protocol suite layer responsible for splitting the webpage data into packets and adding sequence numbers.
(ii) Describe how routers use the packet header to direct packets across the internet, and list three items of metadata typically stored in a packet header.
查看答案詳解

解題

a) The process starts when the user enters the URL into the browser [Step 1: C]. The browser must first resolve the IP address, so it requests it from the DNS server [Step 2: F]. The DNS server searches its records [Step 3: B] and returns the IP address to the browser [Step 4: E]. Once the browser has the IP, it sends an HTTP/HTTPS request directly to the web server [Step 5: A]. Finally, the web server processes this request and returns the webpage files [Step 6: D].

b) (i) The Transport Layer is responsible for segmenting/splitting data into packets and adding sequence numbers.
(ii) Routers inspect the destination IP address in the packet header and consult routing tables to forward the packet to the next hop. Three metadata items in the header include: Source IP address, Destination IP address, and Packet sequence number.

評分準則

a) [Max 3 marks]
Award 0.5 marks for each correct position:
- 1st = C
- 2nd = F
- 3rd = B
- 4th = E
- 5th = A
- 6th = D

b) (i) [Max 1 mark]
- 1 mark for Transport Layer (Accept: TCP / Transmission Control Protocol)

(ii) [Max 2.5 marks]
- 1 mark for routing description: 0.5 marks for stating the router reads the destination IP address from the header; 0.5 marks for stating it uses a routing table/algorithm to forward the packet to the next node/hop.
- 1.5 marks for listing three metadata items (0.5 marks per item, max 3): Source IP address, Destination IP address, Packet sequence number (accept: Packet size / length, Checksum, Protocol version).

卷二 Problem-solving (Algorithms, Programming and Logic)

Answer all questions. Write pseudocode or program code. Total marks: 75.
13 題目 · 70.97999999999999
題目 1 · Flowchart correction and completion
5
An algorithm is intended to input 50 numbers, count how many of these numbers are positive (greater than 0), and then output the final count of positive numbers.

The flowchart below has been designed for this purpose but contains two missing statements (labeled Box A and Box B) and three logical errors.

[Start]

[PositiveCount = 0]

[LoopCount = 0]

┌─> [ Box A ]
│ │
│ 0?> ─────── Yes ───> [PositiveCount = PositiveCount + Num]
│ │ │
│ No │
│ │ <───────────────────────┘
│ │
│ [LoopCount = LoopCount + 1]
│ │
│ < Box B > ─── Yes ───> [OUTPUT LoopCount] ───> [End]
│ │
└──── No

Note: The 'No' line from the decision box Box B mistakenly loops back to the 'PositiveCount = 0' step instead of the entry point above Box A.

(a) State the correct pseudocode statements to complete Box A and Box B. [2]
(b) Identify the three logical errors in this flowchart and state the correct flowchart action/condition for each. [3]
查看答案詳解

解題

Part (a):
- Box A is the step where each number is read from the user. Therefore, it must be an input statement: `INPUT Num`.
- Box B is the loop termination condition. Since the count starts at 0 and increments by 1 each iteration, and the loop exits on 'Yes', the condition must check if 50 numbers have been processed: `LoopCount = 50?`.

Part (b):
- Error 1: The process block `PositiveCount = PositiveCount + Num` adds the actual value of the input number instead of incrementing the count of positive numbers. It must be changed to `PositiveCount = PositiveCount + 1`.
- Error 2: The output block `OUTPUT LoopCount` prints the total number of iterations instead of the positive number count. It must be changed to `OUTPUT PositiveCount`.
- Error 3: The 'No' path of the decision box loops back to `PositiveCount = 0`, resetting the counter every iteration. It must loop back to Box A to input the next number.

評分準則

Part (a): [2 marks]
- 1 mark for Box A: INPUT Num (accept any equivalent read statement, e.g., READ Num)
- 1 mark for Box B: LoopCount = 50? (accept LoopCount >= 50? or LoopCount == 50)

Part (b): [3 marks]
- 1 mark for identifying and correcting the accumulation error: `PositiveCount = PositiveCount + 1`
- 1 mark for identifying and correcting the output error: `OUTPUT PositiveCount`
- 1 mark for identifying and correcting the loop-back line error: Line should return to Box A/input step (not reset the variable)
題目 2 · Flowchart correction and completion
5
An algorithm is designed to find the minimum value in an array Values[1:100] and output both this minimum value and the array index where it was found.

The flowchart below contains two missing process steps (labeled Box X and Box Y) and three logical errors.

[Start]

[Min = Values[1]]

[MinIndex = 1]

[ Box X ]

┌─> ─── No ───> [OUTPUT Min, Index] ───> [End]
│ │
│ Yes
│ │
│ Min?> ─── Yes ───> [Min = Values[Index]]
│ │ [MinIndex = Min]
│ No │
│ │ <─────────────────────────────────┘
│ │
│ [ Box Y ]
│ │
└─────┘

(a) State the correct pseudocode statements to complete Box X and Box Y. [2]
(b) Identify the three logical errors in this flowchart and state the correct flowchart action/condition for each. [3]
查看答案詳解

解題

Part (a):
- Box X: Since the first element is already set as the minimum, we must initialize the loop index variable. The index should start at 2 to compare the remaining elements: `Index = 2`.
- Box Y: This is the increment step at the end of each iteration of the loop to move to the next index: `Index = Index + 1`.

Part (b):
- Error 1: The comparison `Values[Index] > Min?` would find the maximum value rather than the minimum. It should be changed to `Values[Index] < Min?`.
- Error 2: The assignment `MinIndex = Min` assigns the value of the minimum number to the index tracker, which is incorrect. It should store the position of the value: `MinIndex = Index`.
- Error 3: The final output block `OUTPUT Min, Index` outputs the loop counter's final value (which is 101) instead of the actual index where the minimum value was found. It must be corrected to `OUTPUT Min, MinIndex`.

評分準則

Part (a): [2 marks]
- 1 mark for Box X: Index = 2 (accept Index = 1)
- 1 mark for Box Y: Index = Index + 1

Part (b): [3 marks]
- 1 mark for identifying and correcting comparison operator error: Values[Index] < Min?
- 1 mark for identifying and correcting index tracking assignment error: MinIndex = Index
- 1 mark for identifying and correcting output error: OUTPUT Min, MinIndex
題目 3 · Trace Tables and dry runs
5
An algorithm is represented by the following pseudocode:

```
DECLARE Numbers : ARRAY[1:5] OF INTEGER
Numbers[1] <- 12
Numbers[2] <- 5
Numbers[3] <- 8
Numbers[4] <- 14
Numbers[5] <- 3

Count <- 0
Sum <- 0
Index <- 1

WHILE (Index <= 5) AND (Sum < 25) DO
IF Numbers[Index] MOD 2 = 0 THEN
Sum <- Sum + Numbers[Index]
Count <- Count + 1
ELSE
Sum <- Sum - Numbers[Index]
ENDIF
Index <- Index + 1
ENDWHILE

OUTPUT "Final Sum: ", Sum
OUTPUT "Count: ", Count
```

Complete the trace table for this algorithm.

| Index | Sum | Count | OUTPUT |
|---|---|---|---|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
查看答案詳解

解題

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

1. **Initialization**:
- `Numbers` is populated: `[12, 5, 8, 14, 3]`
- `Count` is initialized to `0`.
- `Sum` is initialized to `0`.
- `Index` is initialized to `1`.

2. **First loop condition check**:
- `Index <= 5` (1 <= 5 is True) AND `Sum < 25` (0 < 25 is True). Enter loop.

3. **First Iteration (Index = 1)**:
- `Numbers[1]` is `12`.
- `12 MOD 2 = 0` is True.
- `Sum` becomes `Sum + 12 = 12`.
- `Count` becomes `0 + 1 = 1`.
- `Index` becomes `2`.

4. **Second loop condition check**:
- `Index <= 5` (2 <= 5 is True) AND `Sum < 25` (12 < 25 is True). Enter loop.

5. **Second Iteration (Index = 2)**:
- `Numbers[2]` is `5`.
- `5 MOD 2 = 0` is False.
- `Sum` becomes `Sum - 5 = 7`.
- `Index` becomes `3`.

6. **Third loop condition check**:
- `Index <= 5` (3 <= 5 is True) AND `Sum < 25` (7 < 25 is True). Enter loop.

7. **Third Iteration (Index = 3)**:
- `Numbers[3]` is `8`.
- `8 MOD 2 = 0` is True.
- `Sum` becomes `Sum + 8 = 15`.
- `Count` becomes `1 + 1 = 2`.
- `Index` becomes `4`.

8. **Fourth loop condition check**:
- `Index <= 5` (4 <= 5 is True) AND `Sum < 25` (15 < 25 is True). Enter loop.

9. **Fourth Iteration (Index = 4)**:
- `Numbers[4]` is `14`.
- `14 MOD 2 = 0` is True.
- `Sum` becomes `Sum + 14 = 29`.
- `Count` becomes `2 + 1 = 3`.
- `Index` becomes `5`.

10. **Fifth loop condition check**:
- `Index <= 5` (5 <= 5 is True) BUT `Sum < 25` (29 < 25 is False).
- The loop terminates because one of the conditions (Sum < 25) is now False.

11. **Outputs**:
- The first OUTPUT statement displays: `Final Sum: 29`
- The second OUTPUT statement displays: `Count: 3`

評分準則

Marks are awarded as follows (up to a maximum of 5 marks):
- **1 mark**: Correct initial values for Sum (0) and Count (0) and Index (1).
- **1 mark**: Correct updates for the first loop iteration (Sum becomes 12, Count becomes 1, Index becomes 2).
- **1 mark**: Correct updates for the second iteration (Sum decreases to 7, Index becomes 3; Count remains unchanged or left blank to indicate no change).
- **1 mark**: Correct updates for the remaining loop iterations (Sum updates to 15 then 29, Count updates to 2 then 3, Index updates to 4 then 5).
- **1 mark**: Correct final output column values showing both "Final Sum: 29" and "Count: 3" on separate rows or clearly labeled.

*Note: Allow minor syntax variations in the output (e.g., omitting quotation marks or colons, as long as the numbers 29 and 3 are present in the correct order).*
*Accept values written on the same or consecutive rows as long as the state changes are correct and in sequence.*
題目 4 · Algorithm debug
4
The pseudocode algorithm below is intended to input 10 temperature readings, count how many of these are below 0 (freezing), and find the lowest temperature recorded.

01 FreezingCount <- 0
02 MinTemp <- 100
03 FOR Counter <- 1 TO 9
04 OUTPUT "Enter temperature: "
05 INPUT Temp
06 IF Temp < 0 THEN
07 FreezingCount <- FreezingCount + Temp
08 ENDIF
09 IF Temp > MinTemp THEN
10 MinTemp <- Temp
11 ENDIF
12 NEXT Counter
13 OUTPUT "Number of freezing days: ", Temp
14 OUTPUT "Lowest temperature: ", MinTemp

Identify the four errors in the pseudocode and write the corrected lines of code.
查看答案詳解

解題

To correct the algorithm, the following lines need to be changed:

1. Loop range (Line 03): The loop is meant to run 10 times, but 'FOR Counter <- 1 TO 9' only runs 9 times. Correct line: FOR Counter <- 1 TO 10
2. Counter increment (Line 07): To count freezing days, we must increment 'FreezingCount' by 1, not add the temperature value itself. Correct line: FreezingCount <- FreezingCount + 1
3. Minimum comparison (Line 09): To find the lowest temperature, we check if 'Temp' is less than 'MinTemp'. Correct line: IF Temp < MinTemp THEN
4. Correct output variable (Line 13): The final output must show the value stored in 'FreezingCount', not the last entered temperature 'Temp'. Correct line: OUTPUT "Number of freezing days: ", FreezingCount

評分準則

Award 1 mark for each correct identification and correction of an error, up to a maximum of 4 marks:
- Line 03 corrected to: FOR Counter <- 1 TO 10 (or equivalent loop to run 10 times)
- Line 07 corrected to: FreezingCount <- FreezingCount + 1 (or equivalent count increment)
- Line 09 corrected to: IF Temp < MinTemp THEN (or equivalent minimum check)
- Line 13 corrected to: OUTPUT "Number of freezing days: ", FreezingCount (or equivalent correct variable output)
題目 5 · written
3
Write a pseudocode segment to input a student's percentage exam mark and validate that it is between 0 and 100 inclusive. The segment must repeat the input process if an invalid mark is entered, outputting an appropriate error message each time.
查看答案詳解

解題

An elegant way to solve this is using a conditional loop (either a WHILE loop or a REPEAT...UNTIL loop).

**Example 1: Using a WHILE loop**
```
OUTPUT "Enter exam mark:"
INPUT Mark
WHILE Mark < 0 OR Mark > 100 DO
OUTPUT "Invalid mark. Please enter a value between 0 and 100:"
INPUT Mark
ENDWHILE
```

**Example 2: Using a REPEAT...UNTIL loop**
```
REPEAT
OUTPUT "Enter exam mark:"
INPUT Mark
IF Mark < 0 OR Mark > 100 THEN
OUTPUT "Error: Mark must be between 0 and 100."
ENDIF
UNTIL Mark >= 0 AND Mark <= 100
```

評分準則

1 mark per point up to a maximum of 3:
- Correct loop structure that repeats until valid or while invalid (e.g. `WHILE Mark < 0 OR Mark > 100` or `UNTIL Mark >= 0 AND Mark <= 100`)
- Outputting an appropriate error message when the mark is out of range
- Prompting and taking input for the mark initially and/or within the loop to allow correction
題目 6 · written
3
An online banking system requires a user to set up a PIN. Write a pseudocode segment that inputs the PIN as a string and validates that its length is exactly 4 characters. The segment must continuously prompt the user and re-input the PIN if the length is invalid, displaying a clear error message.
查看答案詳解

解題

This can be solved using either a `WHILE` or a `REPEAT...UNTIL` loop checking the length of the string using the built-in `LENGTH()` function.

**Example 1: Using a WHILE loop**
```
OUTPUT "Enter 4-digit PIN:"
INPUT Pin
WHILE LENGTH(Pin) <> 4 DO
OUTPUT "Error: PIN must be exactly 4 characters. Re-enter:"
INPUT Pin
ENDWHILE
```

**Example 2: Using a REPEAT...UNTIL loop**
```
REPEAT
OUTPUT "Enter 4-digit PIN:"
INPUT Pin
IF LENGTH(Pin) <> 4 THEN
OUTPUT "Error: PIN length must be 4."
ENDIF
UNTIL LENGTH(Pin) = 4
```

評分準則

1 mark per point up to a maximum of 3:
- Correct use of loop structure to repeat while/until length is validated (e.g. `WHILE LENGTH(Pin) <> 4` or `UNTIL LENGTH(Pin) = 4`)
- Correct use of `LENGTH()` function to check the string size
- Outputting an error message and inputting a new PIN if the validation check fails
題目 7 · database_query
4
A database table named PLANTS is used to store information about botanical specimens in a greenhouse. The table has the following fields: PlantID (Primary Key), SpeciesName, Category (e.g., 'Fern', 'Orchid', 'Cactus'), WateringInterval (number of days between waterings), and Price.

Write an SQL query to display the SpeciesName and Price for all plants where the Category is 'Orchid' and the WateringInterval is 7 days or more. The output list must be sorted by Price in ascending order.
查看答案詳解

解題

To select the required fields, we use:
SELECT SpeciesName, Price
To specify the source table, we use:
FROM PLANTS
To filter by the criteria, we use a compound condition:
WHERE Category = 'Orchid' AND WateringInterval >= 7
To sort the results, we use:
ORDER BY Price (implicitly ascending, or explicitly ORDER BY Price ASC)

評分準則

1 mark for: SELECT SpeciesName, Price
1 mark for: FROM PLANTS
1 mark for: WHERE Category = 'Orchid' AND WateringInterval >= 7
1 mark for: ORDER BY Price (or ORDER BY Price ASC)
(Subtract 1 mark overall if major syntax errors exist, such as missing spaces or incorrect logical operators. Accept single or double quotes around strings. Ignore trailing semicolons.)
題目 8 · database_query
4
A gym database contains a table named MEMBERS that stores details about its club members. The fields in the table are: MemberID (Primary Key), FullName, MembershipType (e.g., 'Gold', 'Silver', 'Bronze'), JoinDate, MonthlyFee, and Active (TRUE or FALSE).

Write an SQL query to display the FullName and MonthlyFee of all active members (where Active is TRUE) whose MonthlyFee is greater than 50.00. The list must be sorted in descending order of MonthlyFee.
查看答案詳解

解題

To retrieve the correct fields:
SELECT FullName, MonthlyFee
To identify the target table:
FROM MEMBERS
To apply the filtering criteria (using boolean status and fee range):
WHERE Active = TRUE AND MonthlyFee > 50.00 (or Active = 1 AND MonthlyFee > 50.00)
To sort the output in descending order:
ORDER BY MonthlyFee DESC

評分準則

1 mark for: SELECT FullName, MonthlyFee
1 mark for: FROM MEMBERS
1 mark for: WHERE Active = TRUE AND MonthlyFee > 50.00 (Accept Active = 1 or Active = 'TRUE')
1 mark for: ORDER BY MonthlyFee DESC
(Do not award the sorting mark if 'DESC' is missing. Ignore trailing semicolons.)
題目 9 · short_answer
2.66
An automated greenhouse irrigation system operates based on three sensors: Soil Moisture (M), Temperature (T), and Water Level (W). The system should turn on the water pump (P = 1) if: the soil moisture is low (M = 0) AND the temperature is high (T = 1), OR the soil moisture is low (M = 0) AND the water level is adequate (W = 1). Write a Boolean expression to represent this logic system.
查看答案詳解

解題

To find the Boolean expression, we represent each sensor condition. 1. 'soil moisture is low (M = 0)' is represented as NOT M. 2. 'temperature is high (T = 1)' is represented as T. This gives the first term: (NOT M AND T). 3. 'water level is adequate (W = 1)' is represented as W. This gives the second term: (NOT M AND W). The two terms are joined by OR because either condition being true turns on the pump. Therefore, the complete expression is: P = (NOT M AND T) OR (NOT M AND W). Note that the factored expression P = NOT M AND (T OR W) is also correct and equivalent.

評分準則

1 mark for correctly representing low soil moisture as NOT M. 1 mark for combining conditions with the correct AND operators. 0.66 marks for correctly combining the two main conditions with OR and appropriate parentheses.
題目 10 · short_answer
2.66
A safety system for a chemical process uses three inputs: A (Pressure normal = 1, high = 0), B (Temperature normal = 1, high = 0), and C (Emergency override active = 1, inactive = 0). The alarm (X) is triggered (X = 1) by the following logic expression: X = NOT (A AND B) AND NOT C. Determine the output value of X for the following two conditions. Condition 1: A = 1, B = 0, C = 0. Condition 2: A = 1, B = 1, C = 1.
查看答案詳解

解題

For Condition 1 (A = 1, B = 0, C = 0): A AND B is 1 AND 0 = 0. NOT (A AND B) is NOT 0 = 1. NOT C is NOT 0 = 1. Thus, X = 1 AND 1 = 1. For Condition 2 (A = 1, B = 1, C = 1): A AND B is 1 AND 1 = 1. NOT (A AND B) is NOT 1 = 0. NOT C is NOT 1 = 0. Thus, X = 0 AND 0 = 0.

評分準則

1.33 marks for evaluating Condition 1 correctly (showing intermediate steps). 1.33 marks for evaluating Condition 2 correctly (showing intermediate steps).
題目 11 · short_answer
2.66
For the given logic expression Q = (A OR NOT B) AND (B XOR C), determine the output value of Q for the following input combinations. Row 1: A = 0, B = 1, C = 0. Row 2: A = 1, B = 0, C = 1.
查看答案詳解

解題

For Row 1 (A = 0, B = 1, C = 0): (A OR NOT B) becomes (0 OR NOT 1) = (0 OR 0) = 0. (B XOR C) becomes (1 XOR 0) = 1. Thus, Q = 0 AND 1 = 0. For Row 2 (A = 1, B = 0, C = 1): (A OR NOT B) becomes (1 OR NOT 0) = (1 OR 1) = 1. (B XOR C) becomes (0 XOR 1) = 1. Thus, Q = 1 AND 1 = 1.

評分準則

1.33 marks for correctly evaluating Row 1 with working. 1.33 marks for correctly evaluating Row 2 with working.
題目 12 · Scenario-based
15
A swimming club needs a program to record and analyze the trial times of 20 swimmers. Each swimmer completes three trials of a 50-metre race.

Write an algorithm, using pseudocode or program code, that meets the following requirements:
- Inputs and validates the following data for 20 swimmers:
- Swimmer ID: must be an integer between 100 and 999 inclusive.
- Swimmer Name: must not be empty.
- Three trial times: each must be a real number greater than 15.0 and less than 120.0 seconds.
- Calculates and stores the average trial time for each swimmer.
- Identifies and outputs:
- The name, ID, and average trial time of the swimmer with the fastest average time (i.e. the lowest average time).
- The name, ID, and average trial time of the swimmer with the slowest average time (i.e. the highest average time).
- The overall average trial time for all 20 swimmers combined.

You must use appropriate variable names and data structures.
All inputs must be validated using loops.
查看答案詳解

解題

Below is a sample pseudocode solution conforming to the Cambridge IGCSE standard:

```pseudocode
DECLARE SwimmerID : ARRAY[1:20] OF INTEGER
DECLARE SwimmerName : ARRAY[1:20] OF STRING
DECLARE AverageTime : ARRAY[1:20] OF REAL
DECLARE TotalAllAverages : REAL
DECLARE FastestIndex, SlowestIndex : INTEGER
DECLARE TempID, j : INTEGER
DECLARE TempName : STRING
DECLARE TempTime, TotalTime, OverallAverage : REAL

TotalAllAverages <- 0.0

FOR i <- 1 TO 20
REPEAT
OUTPUT "Enter Swimmer ID (100-999): "
INPUT TempID
UNTIL TempID >= 100 AND TempID <= 999
SwimmerID[i] <- TempID

REPEAT
OUTPUT "Enter Swimmer Name: "
INPUT TempName
UNTIL TempName <> ""
SwimmerName[i] <- TempName

TotalTime <- 0.0
FOR j <- 1 TO 3
REPEAT
OUTPUT "Enter trial ", j, " time: "
INPUT TempTime
UNTIL TempTime > 15.0 AND TempTime < 120.0
TotalTime <- TotalTime + TempTime
NEXT j

AverageTime[i] <- TotalTime / 3.0
TotalAllAverages <- TotalAllAverages + AverageTime[i]
NEXT i

FastestIndex <- 1
SlowestIndex <- 1

FOR i <- 2 TO 20
IF AverageTime[i] < AverageTime[FastestIndex] THEN
FastestIndex <- i
ENDIF
IF AverageTime[i] > AverageTime[SlowestIndex] THEN
SlowestIndex <- i
ENDIF
NEXT i

OverallAverage <- TotalAllAverages / 20.0

OUTPUT "Fastest Swimmer:"
OUTPUT "ID: ", SwimmerID[FastestIndex]
OUTPUT "Name: ", SwimmerName[FastestIndex]
OUTPUT "Average Time: ", AverageTime[FastestIndex], " seconds"

OUTPUT "Slowest Swimmer:"
OUTPUT "ID: ", SwimmerID[SlowestIndex]
OUTPUT "Name: ", SwimmerName[SlowestIndex]
OUTPUT "Average Time: ", AverageTime[SlowestIndex], " seconds"

OUTPUT "Overall Average of all swimmers: ", OverallAverage, " seconds"
```

評分準則

Marking Scheme (Max 15 marks):
- 1 mark: Correct loop structure to repeat the entry process for exactly 20 swimmers.
- 1 mark: Input and validation loop (e.g. REPEAT...UNTIL) for Swimmer ID checking range 100 to 999 inclusive.
- 1 mark: Input and validation loop for Swimmer Name checking for non-empty input.
- 1 mark: Correct nested loop to input exactly 3 trial times per swimmer.
- 1 mark: Input and validation loop for trial times checking the bounds (> 15.0 and < 120.0).
- 1 mark: Correct calculation of each individual swimmer's average trial time (sum of 3 trials / 3.0).
- 1 mark: Storing IDs, Names, and calculated Average Times in suitable arrays (or equivalent data structures) with consistent indexing.
- 1 mark: Initializing accumulator variable(s) for the overall average to 0.0.
- 1 mark: Correctly accumulating individual average times (or total trial times) within the loop.
- 1 mark: Initializing tracking variables (e.g., FastestIndex / SlowestIndex or FastestTime / SlowestTime) correctly before search.
- 1 mark: Comparison loop checking all swimmers to find the minimum (fastest) average time.
- 1 mark: Comparison loop checking all swimmers to find the maximum (slowest) average time.
- 1 mark: Calculating the overall average for all 20 swimmers after the loop (total accumulated / 20.0).
- 1 mark: Clear outputs for the fastest swimmer's details (ID, name, average time).
- 1 mark: Clear outputs for the slowest swimmer's details (ID, name, average time) AND the overall average.

Accept/Reject Notes:
- Accept solutions written in any clear programming language (Python, VB.NET, Java, etc.) or pseudocode.
- Reject solutions that do not perform input validation loops for IDs, names, and trial times.
題目 13 · Scenario-based
15
A swimming club needs a program to record and analyze the trial times of 20 swimmers. Each swimmer completes three trials of a 50-metre race.

Write an algorithm, using pseudocode or program code, that meets the following requirements:
- Inputs and validates the following data for 20 swimmers:
- Swimmer ID: must be an integer between 100 and 999 inclusive.
- Swimmer Name: must not be empty.
- Three trial times: each must be a real number greater than 15.0 and less than 120.0 seconds.
- Calculates and stores the average trial time for each swimmer.
- Identifies and outputs:
- The name, ID, and average trial time of the swimmer with the fastest average time (i.e. the lowest average time).
- The name, ID, and average trial time of the swimmer with the slowest average time (i.e. the highest average time).
- The overall average trial time for all 20 swimmers combined.

You must use appropriate variable names and data structures.
All inputs must be validated using loops.
查看答案詳解

解題

Below is a sample pseudocode solution conforming to the Cambridge IGCSE standard:

```pseudocode
DECLARE SwimmerID : ARRAY[1:20] OF INTEGER
DECLARE SwimmerName : ARRAY[1:20] OF STRING
DECLARE AverageTime : ARRAY[1:20] OF REAL
DECLARE TotalAllAverages : REAL
DECLARE FastestIndex, SlowestIndex : INTEGER
DECLARE TempID, j : INTEGER
DECLARE TempName : STRING
DECLARE TempTime, TotalTime, OverallAverage : REAL

TotalAllAverages <- 0.0

FOR i <- 1 TO 20
REPEAT
OUTPUT "Enter Swimmer ID (100-999): "
INPUT TempID
UNTIL TempID >= 100 AND TempID <= 999
SwimmerID[i] <- TempID

REPEAT
OUTPUT "Enter Swimmer Name: "
INPUT TempName
UNTIL TempName <> ""
SwimmerName[i] <- TempName

TotalTime <- 0.0
FOR j <- 1 TO 3
REPEAT
OUTPUT "Enter trial ", j, " time: "
INPUT TempTime
UNTIL TempTime > 15.0 AND TempTime < 120.0
TotalTime <- TotalTime + TempTime
NEXT j

AverageTime[i] <- TotalTime / 3.0
TotalAllAverages <- TotalAllAverages + AverageTime[i]
NEXT i

FastestIndex <- 1
SlowestIndex <- 1

FOR i <- 2 TO 20
IF AverageTime[i] < AverageTime[FastestIndex] THEN
FastestIndex <- i
ENDIF
IF AverageTime[i] > AverageTime[SlowestIndex] THEN
SlowestIndex <- i
ENDIF
NEXT i

OverallAverage <- TotalAllAverages / 20.0

OUTPUT "Fastest Swimmer:"
OUTPUT "ID: ", SwimmerID[FastestIndex]
OUTPUT "Name: ", SwimmerName[FastestIndex]
OUTPUT "Average Time: ", AverageTime[FastestIndex], " seconds"

OUTPUT "Slowest Swimmer:"
OUTPUT "ID: ", SwimmerID[SlowestIndex]
OUTPUT "Name: ", SwimmerName[SlowestIndex]
OUTPUT "Average Time: ", AverageTime[SlowestIndex], " seconds"

OUTPUT "Overall Average of all swimmers: ", OverallAverage, " seconds"
```

評分準則

Marking Scheme (Max 15 marks):
- 1 mark: Correct loop structure to repeat the entry process for exactly 20 swimmers.
- 1 mark: Input and validation loop (e.g. REPEAT...UNTIL) for Swimmer ID checking range 100 to 999 inclusive.
- 1 mark: Input and validation loop for Swimmer Name checking for non-empty input.
- 1 mark: Correct nested loop to input exactly 3 trial times per swimmer.
- 1 mark: Input and validation loop for trial times checking the bounds (> 15.0 and < 120.0).
- 1 mark: Correct calculation of each individual swimmer's average trial time (sum of 3 trials / 3.0).
- 1 mark: Storing IDs, Names, and calculated Average Times in suitable arrays (or equivalent data structures) with consistent indexing.
- 1 mark: Initializing accumulator variable(s) for the overall average to 0.0.
- 1 mark: Correctly accumulating individual average times (or total trial times) within the loop.
- 1 mark: Initializing tracking variables (e.g., FastestIndex / SlowestIndex or FastestTime / SlowestTime) correctly before search.
- 1 mark: Comparison loop checking all swimmers to find the minimum (fastest) average time.
- 1 mark: Comparison loop checking all swimmers to find the maximum (slowest) average time.
- 1 mark: Calculating the overall average for all 20 swimmers after the loop (total accumulated / 20.0).
- 1 mark: Clear outputs for the fastest swimmer's details (ID, name, average time).
- 1 mark: Clear outputs for the slowest swimmer's details (ID, name, average time) AND the overall average.

Accept/Reject Notes:
- Accept solutions written in any clear programming language (Python, VB.NET, Java, etc.) or pseudocode.
- Reject solutions that do not perform input validation loops for IDs, names, and trial times.

想知道自己有幾分把握?

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

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

免費開始練習