An original Thinka practice paper modelled on the structure and difficulty of the Jun 2025 (V2) Cambridge International A Level Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
卷一 Computer Systems
Answer all questions. Calculators must not be used.
24 題目 · 75 分
題目 1 · Short Answer
2 分
State two reasons why computer program developers use hexadecimal representation instead of binary representation to display memory addresses.
查看答案詳解收起答案詳解
解題
1. Hexadecimal is easier for humans to read and write than binary, which reduces human errors when entering or interpreting values. 2. Hexadecimal is much shorter and more compact than binary, allowing long memory addresses to be displayed in a cleaner format.
評分準則
1 mark for each valid reason, up to a maximum of 2 marks. Correct reasons include: easier for humans to read/write/understand; less likely to make transcribing errors; it is more compact / uses fewer digits; easier to debug. Do not accept: 'takes up less storage/memory in a computer'.
題目 2 · Short Answer
2 分
An Integrated Development Environment (IDE) contains tools to support the writing and testing of programs. Identify and describe the purpose of two different tools commonly found in an IDE.
查看答案詳解收起答案詳解
解題
An IDE typically contains several development tools. Candidates must identify two tools and describe how they work. Examples include: Syntax Highlighting (displays keywords in different colors to spot errors easily), Auto-completion (predicts/completes words to reduce typing errors and speed up development), Error Diagnostics/Debugger (helps trace execution and pinpoint bugs with breakpoints or watch windows).
評分準則
1 mark for each correct identification and description of a tool, up to a maximum of 2 marks. (e.g., 1 mark for identifying syntax highlighting and describing its purpose, 1 mark for identifying auto-completion/debugger and describing its purpose).
題目 3 · Short Answer
2 分
Robotics is a key area of automated technology. State two key characteristics that define a robot.
查看答案詳解收起答案詳解
解題
A robot is typically defined by having a physical/mechanical structure, being programmable (autonomous behavior), and having sensors to detect aspects of its environment alongside actuators to perform physical movements.
評分準則
1 mark for each valid characteristic, up to a maximum of 2 marks. Accept: Has a physical structure/body; Has sensors to detect environmental factors; Has actuators to move parts / perform physical actions; Is programmable / can make autonomous decisions.
題目 4 · Short Answer
2 分
During the fetch-decode-execute cycle, registers are used to hold data and instructions. Describe the purpose of the Program Counter (PC) in this cycle.
查看答案詳解收起答案詳解
解題
The Program Counter (PC) is a dedicated CPU register. Its main purpose is to hold the address of the next instruction that needs to be fetched from memory. Once that instruction is fetched, the PC is incremented so that it points to the subsequent instruction in memory.
評分準則
1 mark for stating that it holds the address of the next instruction to be fetched. 1 mark for stating that it increments (by 1) to point to the following instruction in memory.
題目 5 · Short Answer
2 分
Explain the difference between the outputs of a two-input OR gate and a two-input XOR gate.
查看答案詳解收起答案詳解
解題
A 2-input OR gate outputs a 1 if input A is 1, input B is 1, or both are 1. A 2-input XOR gate (Exclusive OR) outputs a 1 if input A is 1 or input B is 1, but outputs a 0 if both inputs are 1. The key difference lies in the input state where both inputs are 1.
評分準則
1 mark for explaining that both gates output 1 when only one input is 1. 1 mark for explaining the difference when both inputs are 1 (OR gate outputs 1, while XOR gate outputs 0).
題目 6 · Short Answer
2 分
Phishing and pharming are both security threats designed to steal sensitive user details. State one similarity and one difference between phishing and pharming.
查看答案詳解收起答案詳解
解題
Similarity: Both techniques are designed to trick users into visiting fraudulent websites to harvest sensitive credentials or financial details. Difference: Phishing relies on user action (clicking a link in an email/message), whereas pharming is automated and redirects the user when they type a legitimate URL, usually by installing malicious software or corrupting DNS entries.
評分準則
1 mark for a correct similarity. 1 mark for a correct difference. Acceptable similarity: both aim to steal personal data / credentials / use fake websites. Acceptable difference: phishing uses emails/messages containing links, pharming redirects users automatically / corrupts DNS tables.
題目 7 · Short Answer
2 分
Data transmission can be classified by direction. Define 'half-duplex' data transmission and provide a real-world example of its use.
查看答案詳解收起答案詳解
解題
Half-duplex transmission allows two-way communication, but the channel is shared such that data can only travel in one direction at any given moment. An example of this is a walkie-talkie, where only one person can speak and transmit while the other listens.
評分準則
1 mark for the definition: data transmission in both directions, but only one direction at a time (both conditions must be met). 1 mark for a valid real-world example (e.g., walkie-talkie, single-lane bridge traffic analogy, citizen band radio).
題目 8 · Short Answer
2 分
Explain how a checksum is used to detect transmission errors in a block of data.
查看答案詳解收起答案詳解
解題
A checksum is calculated using an algorithm on the data block before transmission. The calculated checksum value is appended to the data. Upon receipt, the receiver runs the same algorithm on the received data. If the newly calculated checksum matches the received checksum, the data is assumed to be error-free; otherwise, an error is detected.
評分準則
1 mark for explaining that the checksum is calculated by the sender and transmitted alongside the data block. 1 mark for explaining that the receiver recalculates the checksum and compares it to the received checksum to detect if they match.
題目 9 · structured
3 分
An image file contains an 8-bit color depth value represented by the denary number 213. (i) Convert the denary number 213 into an 8-bit binary number. (ii) Convert your binary answer into hexadecimal.
查看答案詳解收起答案詳解
解題
To convert the denary number 213 to binary: 213 can be decomposed into place values: \(128 + 64 + 16 + 4 + 1 = 213\). Placing a 1 in these positions and 0 elsewhere gives the 8-bit binary number 11010101. To convert this binary number to hexadecimal, split it into two 4-bit nibbles: 1101 (which is 13 in denary, or D in hexadecimal) and 0101 (which is 5 in denary, or 5 in hexadecimal). Combining these gives the hexadecimal value D5.
評分準則
1 mark for showing correct working or place value calculation (e.g., \(128 + 64 + 16 + 4 + 1\)). 1 mark for the correct 8-bit binary value: 11010101. 1 mark for the correct hexadecimal value: D5.
題目 10 · structured
3 分
An 8-bit register contains the binary number 10110110. A second 8-bit register contains the binary number 01001101. (i) Perform the binary addition of these two numbers. (ii) State whether an overflow error occurs and explain why.
查看答案詳解收起答案詳解
解題
Adding 10110110 (182 in denary) and 01001101 (77 in denary) gives a 9-bit result of 100000011 (259 in denary). Since the register is only 8 bits wide, the leftmost bit (the carry-out) is lost, leaving 00000011 in the register. An overflow error occurs because the sum exceeds 255, which is the maximum value that can be represented by 8 bits.
評分準則
1 mark for the correct 8-bit binary sum: 00000011. 1 mark for identifying that an overflow error occurs. 1 mark for explaining that the sum (259) exceeds the maximum limit of an 8-bit register (255) or requires a 9th bit.
題目 11 · structured
3 分
A logic circuit has three inputs: A, B, and C. The output X is represented by the Boolean expression: \(X = (\text{A AND NOT B}) \text{ OR } (\text{B AND C})\). Calculate the value of X when the inputs are: (i) A = 1, B = 0, C = 1; (ii) A = 1, B = 1, C = 0; (iii) A = 0, B = 1, C = 1.
查看答案詳解收起答案詳解
解題
For (i): NOT B is 1, so \(\text{A AND NOT B} = 1 \text{ AND } 1 = 1\). \(\text{B AND C} = 0 \text{ AND } 1 = 0\). \(X = 1 \text{ OR } 0 = 1\). For (ii): NOT B is 0, so \(\text{A AND NOT B} = 1 \text{ AND } 0 = 0\). \(\text{B AND C} = 1 \text{ AND } 0 = 0\). \(X = 0 \text{ OR } 0 = 0\). For (iii): NOT B is 0, so \(\text{A AND NOT B} = 0 \text{ AND } 0 = 0\). \(\text{B AND C} = 1 \text{ AND } 1 = 1\). \(X = 0 \text{ OR } 1 = 1\).
評分準則
1 mark for correct value of X in scenario (i): X = 1. 1 mark for correct value of X in scenario (ii): X = 0. 1 mark for correct value of X in scenario (iii): X = 1.
題目 12 · structured
3 分
An uncompressed audio file has a sample rate of 44,100 Hz, a bit depth of 16 bits, and is recorded in stereo (2 channels). The recording lasts for 10 seconds. Calculate the file size of the recording in megabytes (MB). Show your working. Assume 1 kilobyte (KB) = 1000 bytes and 1 megabyte (MB) = 1000 kilobytes (KB).
1 mark for showing correct multiplication formula: \(44,100 \times 16 \times 2 \times 10\) (or using 2 bytes instead of 16 bits). 1 mark for correct size in bytes (1,764,000 bytes) or bits (14,112,000 bits). 1 mark for correct final conversion to 1.764 MB (accept 1.76 MB).
題目 13 · structured
3 分
An 8-bit register contains the binary number 00111100. (i) Convert the binary number to denary. (ii) Perform a logical shift right of two places on the original binary value. (iii) State the denary effect of this logical shift right of two places.
查看答案詳解收起答案詳解
解題
For (i): The binary value 00111100 has place values of 32, 16, 8, and 4. Summing these gives: \(32 + 16 + 8 + 4 = 60\). For (ii): Shifting the bits two places to the right moves all values rightward, filling the empty spaces on the left with 0s: 00001111. For (iii): 00001111 in denary is \(8 + 4 + 2 + 1 = 15\). Shifting right by two places is equivalent to dividing the original number by 4 (since \(60 / 4 = 15\)).
評分準則
1 mark for correct denary conversion: 60. 1 mark for correct shifted binary value: 00001111. 1 mark for stating that the value has been divided by 4 (or divided by \(2^2\)).
題目 14 · structured
3 分
One of the bytes in a network card's MAC address is represented by the hexadecimal value 3E. (i) Convert the hexadecimal value 3E into an 8-bit binary number. (ii) Convert the hexadecimal value 3E into a denary number. (iii) A second byte has the denary value 91. Convert the denary value 91 into hexadecimal.
查看答案詳解收起答案詳解
解題
For (i): 3 in binary is 0011, and E (which is 14 in denary) in binary is 1110. Combining them gives 00111110. For (ii): 3E in denary is \((3 \times 16) + (14 \times 1) = 48 + 14 = 62\). For (iii): Divide 91 by 16: \(91 / 16 = 5\) remainder 11. The denary remainder 11 is represented by B in hexadecimal. Therefore, the value in hexadecimal is 5B.
評分準則
1 mark for correct binary representation: 00111110 (accept 111110). 1 mark for correct denary value: 62. 1 mark for correct hexadecimal value: 5B (accept 5b).
題目 15 · Structured Explanation & Comparison
4.1 分
Compare an 8-bit unsigned binary integer representation with an 8-bit signed Two's Complement representation. In your explanation, describe how the Most Significant Bit (MSB) differs in function between the two representations, and state the exact range of denary values that can be represented by each system.
查看答案詳解收起答案詳解
解題
An unsigned 8-bit binary representation uses all 8 bits to represent magnitude, where the MSB represents 2^7 (or 128). This gives an overall range of 0 to 255. In contrast, an 8-bit Two's Complement system uses the MSB as a sign bit with a negative value of -128. This allows negative values to be represented, yielding an overall range of -128 to +127. Award 1 mark for MSB as positive 128 in unsigned, 1 mark for MSB as negative -128 in Two's Complement, 1 mark for correct unsigned range (0 to 255), and 1 mark for correct Two's Complement range (-128 to +127).
評分準則
1 mark: Explain that the MSB in 8-bit unsigned representation has a positive value of +128. 1 mark: Explain that the MSB in 8-bit Two's Complement has a negative value of -128. 1 mark: Correctly state that the range of unsigned representation is 0 to 255. 1 mark: Correctly state that the range of Two's Complement representation is -128 to +127.
題目 16 · Structured Explanation & Comparison
4.1 分
A graphic designer needs to send high-quality image files to a printing company, while also uploading smaller preview versions of these images to a website portfolio. Explain why the designer should use lossless compression for the files sent to the printer, and lossy compression for the website preview files. Your answer should compare how each compression type affects the content of the file.
查看答案詳解收起答案詳解
解題
Lossless compression reduces file size without losing any original detail, meaning the file can be reconstructed to its exact original state, which is critical for high-resolution physical printing. Lossy compression permanently deletes redundant or less visible data (such as similar color shades), which greatly reduces the file size for quick web transfer, though it slightly degrades quality. Award 1 mark for identifying lossless maintains all data/quality for printing, 1 mark for explaining lossless allows exact reconstruction, 1 mark for identifying lossy permanently deletes redundant data for web previews, and 1 mark for explaining how lossy achieves faster upload/download times.
評分準則
1 mark: Identify that lossless compression maintains complete image data/quality, preventing pixelation in print. 1 mark: Explain that lossless compression allows the file to be reconstructed to its exact original state. 1 mark: Identify that lossy compression permanently discards redundant or less noticeable data to maximize file size reduction. 1 mark: Explain that lossy compression is ideal for web use because smaller files result in faster loading and transfer speeds.
題目 17 · Structured Explanation & Comparison
4.1 分
Compare serial half-duplex transmission with parallel full-duplex transmission. Your comparison must describe the differences in terms of the number of transmission pathways, the direction of data flow, and their susceptibility to data skewing over long distances.
查看答案詳解收起答案詳解
解題
Serial half-duplex uses a single data pathway to send bits sequentially. Data can flow in both directions but only in one direction at any given time. This is highly reliable over long distances because it does not suffer from skewing. Parallel full-duplex uses multiple physical wires to send several bits (e.g., a byte) at the same time in both directions simultaneously. However, because different wires have slightly different electrical properties, bits can arrive out of order (data skewing) over long distances. Award 1 mark for serial vs parallel pathway explanation, 1 mark for half-duplex vs full-duplex directional flow explanation, 1 mark for explaining why parallel suffers from skewing, and 1 mark for explaining why serial does not suffer from skewing.
評分準則
1 mark: State that serial uses a single pathway for sequential bits, while parallel uses multiple pathways for simultaneous bits. 1 mark: State that half-duplex allows two-way communication but not simultaneously, while full-duplex allows simultaneous two-way communication. 1 mark: Explain that parallel is highly susceptible to data skewing over long distances because bits can arrive out of synchronization. 1 mark: Explain that serial is resistant to data skewing, making it reliable for long-distance transmission.
題目 18 · Structured Explanation & Comparison
4.1 分
During the Fetch stage of the Fetch-Decode-Execute (FDE) cycle, both the Program Counter (PC) and the Memory Address Register (MAR) hold memory addresses. Explain the distinct roles of the PC and the MAR during the Fetch stage, and describe how they interact to locate and retrieve the next instruction.
查看答案詳解收起答案詳解
解題
At the beginning of the Fetch stage, the PC holds the address of the next instruction to be executed. This address is copied from the PC to the MAR. The MAR then holds this memory address so that it can be transmitted via the address bus to locate the correct cell in RAM. While the RAM is accessed, the PC is incremented by 1 to prepare for the subsequent cycle. Award 1 mark for PC holding next instruction address and copying to MAR, 1 mark for MAR holding the active address to access RAM, 1 mark for MAR sending address along the address bus, and 1 mark for PC incrementing by 1 during this stage.
評分準則
1 mark: Explain that the PC holds the memory address of the next instruction and copies it to the MAR. 1 mark: Explain that the MAR holds this copied address of the memory location currently being accessed. 1 mark: Describe how the address in the MAR is sent via the address bus to RAM. 1 mark: Explain that the PC is incremented (by 1) to point to the next instruction while the current address is read.
題目 19 · Structured Explanation & Comparison
4.1 分
A software developer is choosing between using a compiler or an interpreter to translate their newly written high-level program. Compare compilers and interpreters by explaining two advantages of using a compiler and two advantages of using an interpreter during the development and distribution process.
查看答案詳解收起答案詳解
解題
A compiler translates the entire high-level source code into machine code at once, generating a standalone executable file (.exe). Two advantages: 1. The resulting program runs faster because it is pre-translated; 2. The source code is secure as only the executable needs to be distributed. An interpreter translates and executes high-level code line-by-line. Two advantages: 1. Debugging is easier because execution stops immediately on the line containing an error; 2. The program is portable and can run on any platform that has the interpreter installed. Award 1 mark for each of two distinct compiler advantages, and 1 mark for each of two distinct interpreter advantages.
評分準則
1 mark: Identify compiler advantage 1 (e.g., faster execution speed as no translation is needed at runtime). 1 mark: Identify compiler advantage 2 (e.g., code security / executable file can run without the source code). 1 mark: Identify interpreter advantage 1 (e.g., easier debugging / stops immediately at the error line). 1 mark: Identify interpreter advantage 2 (e.g., high portability / no need to recompile for different platforms).
題目 20 · Structured Explanation & Comparison
4.1 分
A school is choosing between installing Solid State Drives (SSDs) or traditional Hard Disk Drives (HDDs) as primary storage in its computers. Compare SSDs and HDDs by explaining how they differ in physical construction and how these physical differences impact their durability and read/write speeds.
查看答案詳解收起答案詳解
解題
HDDs store data magnetically on spinning platters, requiring a physical read/write head to move across the surface. This physical movement makes them susceptible to damage from drops (low durability) and limits their read/write speed due to physical seek times. SSDs store data electronically using flash memory (NAND-based transistors) on silicon chips. Because there are no moving parts, SSDs are highly durable, shock-resistant, and have near-instantaneous read/write speeds. Award 1 mark for describing HDD physical construction, 1 mark for describing SSD physical construction, 1 mark for comparing durability, and 1 mark for comparing read/write speeds.
評分準則
1 mark: Explain HDD construction (spinning magnetic platters and moving read/write heads). 1 mark: Explain SSD construction (flash memory / semiconductor chips / no moving parts). 1 mark: Compare durability (SSDs are highly durable/shock-resistant because they lack moving parts, whereas HDDs are easily damaged). 1 mark: Compare speed (SSDs have much faster read/write speeds because there is no physical latency/seek time).
題目 21 · Structured Explanation & Comparison
4.1 分
Phishing and Pharming are both malicious techniques used to steal sensitive user credentials. Explain the key technical differences between phishing and pharming, focusing on how a user is directed to a fraudulent website in each case, and how a user can identify or prevent these threats.
查看答案詳解收起答案詳解
解題
Phishing relies on deceiving the user through communications such as emails or text messages, requiring active human participation (clicking a link) to redirect them to a fake webpage. Pharming is a silent software-based attack that infects a DNS server or local host files, automatically redirecting the user to a fraudulent web server when they attempt to visit a legitimate site. To prevent phishing, users must inspect email details and links carefully. To prevent pharming, users should verify SSL/TLS certificate details (HTTPS) and use up-to-date anti-malware. Award 1 mark for phishing mechanism, 1 mark for pharming mechanism, 1 mark for comparing user interaction (active click vs automatic redirect), and 1 mark for prevention/detection methods.
評分準則
1 mark: Describe phishing (sending fraudulent emails containing links to fake websites). 1 mark: Describe pharming (installing malicious code on a computer/server to redirect legitimate traffic to fake websites). 1 mark: Explain the difference in execution (phishing requires the user to actively click a link, whereas pharming works automatically even if the correct URL is typed). 1 mark: Identify prevention methods (e.g., examining sender addresses for phishing; checking SSL certificates or using anti-malware/firewalls for pharming).
題目 22 · Structured Explanation & Comparison
4.1 分
NAND and NOR gates are universal logic gates. Compare a 2-input NAND gate with a 2-input NOR gate. Your comparison must explain how their output values differ for the input combination (0,1), and describe how each gate is conceptually constructed by combining basic logic gates (AND, OR, NOT).
查看答案詳解收起答案詳解
解題
A NAND gate is short for 'NOT AND' and is conceptually constructed by connecting the output of a standard AND gate directly into a NOT gate. For the input combination (0,1), an AND gate would output 0, meaning the NAND gate outputs 1. A NOR gate is short for 'NOT OR' and is constructed by connecting the output of an OR gate into a NOT gate. For the input combination (0,1), an OR gate would output 1, meaning the NOR gate outputs 0. Award 1 mark for NAND conceptual construction, 1 mark for NOR conceptual construction, 1 mark for correct NAND output (1) for input (0,1), and 1 mark for correct NOR output (0) for input (0,1).
評分準則
1 mark: Explain that a NAND gate is constructed from an AND gate followed by a NOT gate. 1 mark: Explain that a NOR gate is constructed from an OR gate followed by a NOT gate. 1 mark: State that for the input (0,1), the output of the NAND gate is 1. 1 mark: State that for the input (0,1), the output of the NOR gate is 0.
題目 23 · Structured Explanation & Comparison
4.1 分
A company wants to secure its internal communications. Compare the use of symmetric encryption and asymmetric encryption for this purpose. Your comparison must explain how keys are used in both methods and identify one distinct advantage of each method in this scenario.
查看答案詳解收起答案詳解
解題
Symmetric encryption relies on a single shared key that both sender and receiver must possess; this key is used to both encrypt and decrypt the plaintext. Asymmetric encryption uses a mathematically linked key pair: a public key, which is open to anyone and used to encrypt messages, and a private key, which is kept secret by the owner and used to decrypt messages. Symmetric encryption is highly efficient and faster for bulk data transmission inside an organization, but asymmetric encryption avoids the security risk of sharing decryption keys over a network, making key distribution highly secure.
評分準則
Award up to 4.1 marks: - 1 mark: Identifying that symmetric encryption uses the same key for both encryption and decryption. - 1 mark: Identifying that asymmetric encryption uses a public key for encryption and a distinct private key for decryption. - 1 mark: Stating a valid advantage of symmetric (e.g., faster processing, more efficient for large files, less computational overhead). - 1.1 marks: Stating a valid advantage of asymmetric (e.g., no need to share private keys, avoiding the key distribution intercept risk).
題目 24 · Structured Explanation & Comparison
4.1 分
The Program Counter (PC) and the Memory Address Register (MAR) are two vital registers inside the CPU. Compare the roles of these two registers during the Fetch-Decode-Execute cycle. Your answer must clearly explain what specific address each register holds and how they interact during the fetch stage.
查看答案詳解收起答案詳解
解題
The PC is dedicated to keeping track of the sequence of execution by holding the memory address of the next instruction to be processed. In contrast, the MAR is a temporary holding register that stores the address in main memory (RAM) where the CPU is currently reading from or writing to. At the start of the Fetch stage, the address stored in the PC is copied directly into the MAR. While the MAR holds this address so the memory unit can retrieve the instruction via the address bus, the PC is simultaneously incremented by one so that it is ready for the subsequent cycle.
評分準則
Award up to 4.1 marks: - 1 mark: Correctly stating that the PC holds the address of the next instruction. - 1 mark: Correctly stating that the MAR holds the address of the memory location currently being read from or written to. - 1 mark: Explaining the interaction where the address in the PC is copied into the MAR. - 1.1 marks: Explaining that the PC is incremented immediately after copying, while the MAR maintains the current address for the memory bus transfer.
卷二 Algorithms, Programming and Logic
Answer all questions. Calculators must not be used. Note: Question 10 (15 marks) has been removed.
12 題目 · 44.230000000000004 分
題目 1 · Decomposition / Abstraction Matching
2.66 分
A software developer is designing a new library management system. Identify whether each of the following activities is an example of Abstraction or Decomposition. Match each activity to the correct concept: Activity A: Splitting the system into smaller parts, such as book tracking, member registration, and fee calculation. Activity B: Designing the 'book' object to store only the ISBN, title, and author, and omitting details like page thickness or font size. Activity C: Creating a simplified model of a library user that only includes their membership number and active loans. Activity D: Dividing the member registration task into sub-tasks: validating the input, saving to database, and printing the membership card.
查看答案詳解收起答案詳解
解題
Activity A is Decomposition because it involves breaking down a large, complex system into smaller subsystems. Activity B is Abstraction because it removes unnecessary details of a book object, focusing only on the essential data fields. Activity C is Abstraction because it creates a simplified representation of a library user. Activity D is Decomposition because it breaks a complex task into smaller, manageable sub-tasks.
評分準則
1 mark for each correct match, scaled to a maximum of 2.66 marks. Award marks as follows: 4 correct matches = 2.66 marks, 3 correct matches = 2.0 marks, 2 correct matches = 1.33 marks, 1 correct match = 0.66 marks.
題目 2 · Decomposition / Abstraction Matching
2.66 分
An engineer is designing a simulation of an automated warehouse. Match each of the following design decisions to either Abstraction or Decomposition: Decision 1: Representing a delivery drone as a single point with coordinates (x, y) and a battery level, ignoring its actual physical dimensions and rotor speed. Decision 2: Breaking the main control algorithm down into separate sub-routines: pathfinding, obstacle detection, and battery charging. Decision 3: Grouping the storage racks into separate sections (Aisle A, Aisle B, Aisle C) to be handled by individual software instances. Decision 4: Storing only the weight and destination zip code of a package, while ignoring its contents and packaging material.
查看答案詳解收起答案詳解
解題
Decision 1 represents Abstraction because it models a complex physical object (a drone) using only essential attributes (coordinates and battery level), omitting unnecessary details. Decision 2 represents Decomposition because it divides the main control algorithm into smaller, self-contained sub-routines. Decision 3 represents Decomposition because a large warehousing problem is partitioned into smaller geographical tasks. Decision 4 represents Abstraction because it filters out details about package contents and materials to focus on the essential aspects needed for logistics.
評分準則
1 mark for each correct match, scaled to a maximum of 2.66 marks. Award marks as follows: 4 correct matches = 2.66 marks, 3 correct matches = 2.0 marks, 2 correct matches = 1.33 marks, 1 correct match = 0.66 marks.
題目 3 · Decomposition / Abstraction Matching
2.66 分
A computer science student is writing an algorithm for an online food delivery application. Determine whether each action taken by the student is an example of Abstraction or Decomposition. Action X: Detailing only the total price, estimated delivery time, and restaurant ID for an order, while ignoring the specific ingredients of the dishes. Action Y: Designing a 'driver' entity that only has an ID and current location, leaving out their vehicle type, age, and contact number. Action Z: Breaking down the checkout process into distinct steps: coupon validation, payment gateway communication, and order confirmation. Action W: Dividing the user feedback module into sub-modules: star-rating input, text-comment validation, and database storage.
查看答案詳解收起答案詳解
解題
Action X is Abstraction because it simplifies an order by ignoring the internal specific ingredients. Action Y is Abstraction because it models a driver with only essential attributes (ID and location), filtering out irrelevant personal and vehicle details. Action Z is Decomposition because it breaks down the complex checkout workflow into discrete steps. Action W is Decomposition because it splits a main feedback module into smaller, dedicated sub-modules.
評分準則
1 mark for each correct match, scaled to a maximum of 2.66 marks. Award marks as follows: 4 correct matches = 2.66 marks, 3 correct matches = 2.0 marks, 2 correct matches = 1.33 marks, 1 correct match = 0.66 marks.
題目 4 · Dry Run / Trace Tables
4.5 分
Consider the following pseudocode algorithm:
DECLARE X, Y, Z : INTEGER X ← 3 Y ← 7 Z ← 0 WHILE Y > 0 DO IF Y MOD 2 <> 0 THEN Z ← Z + X ENDIF X ← X * 2 Y ← Y DIV 2 ENDWHILE OUTPUT Z
Complete the trace table below for this algorithm.
| X | Y | Z | Output | |---|---|---|--------| | | | | |
查看答案詳解收起答案詳解
解題
Let's dry run the algorithm step-by-step: 1. X is initialized to 3, Y to 7, and Z to 0. 2. Loop check: Y > 0 (7 > 0) is true. 3. Y MOD 2 <> 0 (7 MOD 2 = 1) is true, so Z becomes Z + X = 0 + 3 = 3. 4. X is multiplied by 2 to become 6. 5. Y is integer divided by 2 to become 3. 6. Loop check: Y > 0 (3 > 0) is true. 7. Y MOD 2 <> 0 (3 MOD 2 = 1) is true, so Z becomes Z + X = 3 + 6 = 9. 8. X becomes 12. 9. Y becomes 1. 10. Loop check: Y > 0 (1 > 0) is true. 11. Y MOD 2 <> 0 (1 MOD 2 = 1) is true, so Z becomes Z + X = 9 + 12 = 21. 12. X becomes 24. 13. Y becomes 0. 14. Loop check: Y > 0 (0 > 0) is false. Loop terminates. 15. Output Z = 21.
評分準則
1 mark for correct initial setup of X, Y, Z (3, 7, 0). 1 mark for correct updates to Z (3, 9, 21). 1 mark for correct updates to X (6, 12, 24) and Y (3, 1, 0). 1 mark for correct final Output (21). 0.5 marks for correct structure and order of trace table progression.
題目 5 · Dry Run / Trace Tables
4.5 分
An algorithm performs a single pass of a sorting mechanism on a 1D array of five numbers:
DECLARE Numbers : ARRAY[1:5] OF INTEGER DECLARE i, Temp, SwapCount : INTEGER Numbers[1] ← 15 Numbers[2] ← 8 Numbers[3] ← 22 Numbers[4] ← 3 Numbers[5] ← 12 SwapCount ← 0 FOR i ← 1 TO 4 IF Numbers[i] > Numbers[i+1] THEN Temp ← Numbers[i] Numbers[i] ← Numbers[i+1] Numbers[i+1] ← Temp SwapCount ← SwapCount + 1 ENDIF NEXT i OUTPUT SwapCount
Complete the trace table below for this algorithm.
1 mark for correct initial setup of array and SwapCount. 1 mark for the first swap (i=1: Numbers[1]=8, Numbers[2]=15, Temp=15, SwapCount=1). 1 mark for correct handling of i=2 (no change) and second swap (i=3: Numbers[3]=3, Numbers[4]=22, Temp=22, SwapCount=2). 1 mark for correct third swap (i=4: Numbers[4]=12, Numbers[5]=22, Temp=22, SwapCount=3). 0.5 marks for correct output (3).
題目 6 · Pseudocode Logic Corrections & Writing
4.25 分
The following pseudocode is intended to search an array `Score` containing 100 test scores (integer values from 0 to 100 at indexes 1 to 100) to count how many scores are strictly above the average score of 75, and output this count.
However, there are three logic errors in the pseudocode:
``` 01 Count <- 0 02 TotalScores <- 0 03 FOR Index <- 0 TO 100 04 IF Score[Index] >= 75 THEN 05 TotalScores <- TotalScores + 1 06 ENDIF 07 NEXT Index 08 OUTPUT "Count of scores above average is ", Count ```
Identify the line number of each error, explain why it is an error, and write the corrected pseudocode line.
查看答案詳解收起答案詳解
解題
To correct this pseudocode: 1. **First Error (Line 03):** The array indexes are 1 to 100. A loop from 0 to 100 attempts to access `Score[0]`, which is out of bounds, and executes 101 times. The corrected loop header must be: `FOR Index <- 1 TO 100`. 2. **Second Error (Line 04):** The condition `Score[Index] >= 75` counts scores that are equal to 75 as well. Since we only want scores strictly above average (75), the operator must be `>`. Corrected line: `IF Score[Index] > 75 THEN`. 3. **Third Error (Line 05 or Line 08):** The loop increments `TotalScores` but the final `OUTPUT` prints `Count`. This results in printing `0` regardless of the actual counts. Corrected line: either change line 05 to `Count <- Count + 1` or change line 08 to `OUTPUT "Count of scores above average is ", TotalScores`.
評分準則
Award marks as follows (total 4.25 marks): - **1.0 Mark** for identifying Line 03 error and correcting it to `FOR Index <- 1 TO 100`. - **1.0 Mark** for identifying Line 04 error and correcting it to `IF Score[Index] > 75 THEN`. - **1.0 Mark** for identifying the mismatch between `TotalScores` and `Count` and correcting either Line 05 (`Count <- Count + 1`) or Line 08 (`OUTPUT ... TotalScores`). - **1.25 Marks** for explaining the reasoning behind all three corrections clearly (e.g., explaining array index out of bounds, strict inequality vs non-strict, and mismatched variable names).
題目 7 · Pseudocode Logic Corrections & Writing
4.25 分
A school library calculates fines for overdue books using the following rules: - If `DaysOverdue` is 0 or less, the fine is $0.00. - If `DaysOverdue` is between 1 and 5 days inclusive, the fine is $0.50 per day. - If `DaysOverdue` is between 6 and 10 days inclusive, the fine is a flat $2.50 (for the first 5 days) plus $1.00 for each additional day over 5 days. - If `DaysOverdue` is greater than 10 days, the fine is a flat $7.50 (for the first 10 days) plus $2.00 for each additional day over 10 days.
Write a pseudocode algorithm that inputs `DaysOverdue` (an integer), calculates the `Fine` (a real number), and outputs a message with the total fine.
查看答案詳解收起答案詳解
解題
The solution requires conditional branching using `IF... ELSEIF... ELSE... ENDIF` to handle different ranges of `DaysOverdue`: 1. Input the value of `DaysOverdue`. 2. For `DaysOverdue <= 0`, set `Fine` to `0.0`. 3. For `DaysOverdue <= 5`, compute `Fine <- DaysOverdue * 0.50`. 4. For `DaysOverdue <= 10`, compute `Fine <- 2.50 + (DaysOverdue - 5) * 1.00`. 5. For anything greater than 10, compute `Fine <- 7.50 + (DaysOverdue - 10) * 2.00`. 6. Output the value of `Fine`.
評分準則
Award marks as follows (total 4.25 marks): - **1.0 Mark** for declaring variables, inputting `DaysOverdue`, and implementing an appropriate conditional structure (e.g., nested `IF` or `IF-ELSEIF`). - **1.0 Mark** for correctly calculating `Fine` for the <=0 and 1 to 5 days conditions (`DaysOverdue <= 0` fine is 0, and `DaysOverdue * 0.50` for <= 5). - **1.0 Mark** for correctly calculating `Fine` for the 6 to 10 days range using the correct base flat fee and calculation: `2.50 + (DaysOverdue - 5) * 1.00`. - **1.25 Marks** for correctly calculating `Fine` for >10 days range (`7.50 + (DaysOverdue - 10) * 2.00`) and outputting the computed `Fine` with appropriate text.
題目 8 · Pseudocode Logic Corrections & Writing
4.25 分
The following pseudocode function is intended to check if a positive integer input, `Num` (where `Num > 1`), is a prime number. If it is prime, the function should return `TRUE`, otherwise it should return `FALSE`.
However, there are three logic errors in the pseudocode:
``` 01 FUNCTION IsPrime(Num : INTEGER) RETURNS BOOLEAN 02 DECLARE IsPrimeNumber : BOOLEAN 03 DECLARE Divisor : INTEGER 04 IsPrimeNumber <- FALSE 05 IF Num <= 1 THEN 06 RETURN FALSE 07 ENDIF 08 FOR Divisor <- 2 TO Num 09 IF Num / Divisor = 0 THEN 10 IsPrimeNumber <- FALSE 11 ENDIF 12 NEXT Divisor 13 RETURN IsPrimeNumber 14 ENDFUNCTION ```
Identify the line number of each error, explain why it is an error, and write the corrected pseudocode line.
查看答案詳解收起答案詳解
解題
To correct the prime checking function: 1. **First Error (Line 04):** We assume a number is prime until proven otherwise. Thus, `IsPrimeNumber` must be initialized to `TRUE`. Corrected line: `IsPrimeNumber <- TRUE`. 2. **Second Error (Line 08):** The loop goes all the way up to `Num`. Since `Num` is always divisible by itself, `Num MOD Num = 0` will evaluate to true for every number, making the function return `FALSE` for all positive integers. The loop must stop before reaching `Num`. Corrected line: `FOR Divisor <- 2 TO Num - 1` or `FOR Divisor <- 2 TO Num DIV 2`. 3. **Third Error (Line 09):** The expression `Num / Divisor = 0` is incorrect because `/` is real division and checking if it equals `0` does not test for divisibility. Divisibility is tested using the modulo operator to see if there is no remainder. Corrected line: `IF Num MOD Divisor = 0 THEN`.
評分準則
Award marks as follows (total 4.25 marks): - **1.0 Mark** for identifying the Line 04 error and correcting the initialization to `TRUE`. - **1.0 Mark** for identifying the Line 08 error and correcting the loop upper limit to stop before `Num` (e.g. `Num - 1` or `Num DIV 2`). - **1.0 Mark** for identifying the Line 09 error and correcting it to use the `MOD` operator to check for a remainder of 0. - **1.25 Marks** for explaining the reasons for all three logic errors correctly (initial flag assumption, division by self, and remainder check vs quotient check).
題目 9 · Pseudocode Logic Corrections & Writing
4.25 分
A programmer is writing a pseudocode algorithm to read names from an existing text file called `"Students.txt"` and write any name that starts with the letter 'A' into a new text file called `"A_Students.txt"`.
However, the following pseudocode contains three errors:
``` 01 OPEN "Students.txt" FOR WRITE 02 OPEN "A_Students.txt" FOR READ 03 WHILE NOT EOF("Students.txt") DO 04 READFILE "Students.txt", StudentName 05 IF SUBSTRING(StudentName, 1, 1) = "A" THEN 06 WRITEFILE "A_Students.txt", StudentName 07 ENDIF 08 ENDWHILE 09 CLOSE "Students.txt" ```
Identify the line number of each error, explain why it is an error, and write the corrected pseudocode line (or add any missing lines).
查看答案詳解收起答案詳解
解題
To correct this file handling algorithm: 1. **First Error (Line 01):** The file `"Students.txt"` contains the original list of names that we need to read. Opening it for `WRITE` would overwrite/clear the file instead of letting us read from it. It must be opened for `READ`. Corrected line: `OPEN "Students.txt" FOR READ`. 2. **Second Error (Line 02):** The file `"A_Students.txt"` is where we are writing matching names. Opening it for `READ` will not allow writing. It must be opened for `WRITE`. Corrected line: `OPEN "A_Students.txt" FOR WRITE`. 3. **Third Error (Line 09 / Missing Line):** All files that are opened must be closed. `"A_Students.txt"` is never closed in the code. A statement is required to close this file. Corrected line: Append `CLOSE "A_Students.txt"` after line 09.
評分準則
Award marks as follows (total 4.25 marks): - **1.0 Mark** for correcting Line 01 to open `
題目 10 · Pseudocode Logic Corrections & Writing
4.25 分
A programmer is writing a pseudocode algorithm to read names from an existing text file called `"Students.txt"` and write any name that starts with the letter 'A' into a new text file called `"A_Students.txt"`.
However, the following pseudocode contains three errors:
``` 01 OPEN "Students.txt" FOR WRITE 02 OPEN "A_Students.txt" FOR READ 03 WHILE NOT EOF("Students.txt") DO 04 READFILE "Students.txt", StudentName 05 IF SUBSTRING(StudentName, 1, 1) = "A" THEN 06 WRITEFILE "A_Students.txt", StudentName 07 ENDIF 08 ENDWHILE 09 CLOSE "Students.txt" ```
Identify the line number of each error, explain why it is an error, and write the corrected pseudocode line (or add any missing lines).
查看答案詳解收起答案詳解
解題
To correct this file handling algorithm: 1. **First Error (Line 01):** The file `"Students.txt"` contains the original list of names that we need to read. Opening it for `WRITE` would overwrite/clear the file instead of letting us read from it. It must be opened for `READ`. Corrected line: `OPEN "Students.txt" FOR READ`. 2. **Second Error (Line 02):** The file `"A_Students.txt"` is where we are writing matching names. Opening it for `READ` will not allow writing. It must be opened for `WRITE`. Corrected line: `OPEN "A_Students.txt" FOR WRITE`. 3. **Third Error (Line 09 / Missing Line):** All files that are opened must be closed. `"A_Students.txt"` is never closed in the code. A statement is required to close this file. Corrected line: Append `CLOSE "A_Students.txt"` after line 09.
評分準則
Award marks as follows (total 4.25 marks): - **1.0 Mark** for correcting Line 01 to open `"Students.txt"` for `READ`. - **1.0 Mark** for correcting Line 02 to open `"A_Students.txt"` for `WRITE`. - **1.0 Mark** for identifying that `"A_Students.txt"` must be closed and adding a `CLOSE` statement for it. - **1.25 Marks** for explaining the reasons for all three corrections clearly (concept of read/write modes and the rule that all opened files must be closed).
題目 11 · short_answer
3 分
A database table, `Flight`, contains information about flights at an airport. The table has the following fields: `FlightNumber`, `Destination`, `DelayMinutes`, and `Status`.
Write a SQL query to display the `FlightNumber` and `DelayMinutes` for all flights with a `Destination` of 'London' and a `DelayMinutes` greater than 15. The output should be sorted from longest delay to shortest delay.
查看答案詳解收起答案詳解
解題
To construct the SQL query: 1. Identfiy the fields to display: `FlightNumber` and `DelayMinutes`. This forms the `SELECT` clause: `SELECT FlightNumber, DelayMinutes`. 2. Identify the table: `Flight`. This forms the `FROM` clause: `FROM Flight`. 3. Identify the conditions: `Destination` must be exactly 'London' and `DelayMinutes` must be greater than 15. This forms the `WHERE` clause: `WHERE Destination = 'London' AND DelayMinutes > 15`. 4. Identify the sorting requirement: from longest delay to shortest delay (descending order) by `DelayMinutes`. This forms the `ORDER BY` clause: `ORDER BY DelayMinutes DESC`.
Combining these elements gives the complete SQL query: `SELECT FlightNumber, DelayMinutes FROM Flight WHERE Destination = 'London' AND DelayMinutes > 15 ORDER BY DelayMinutes DESC;`
評分準則
1 mark for correct SELECT and FROM clauses: - `SELECT FlightNumber, DelayMinutes FROM Flight` (Accept with or without table prefix, e.g., `Flight.FlightNumber`)
1 mark for correct WHERE clause: - `WHERE Destination = 'London' AND DelayMinutes > 15` (Accept double quotes for "London", accept reversed condition order, e.g. `DelayMinutes > 15 AND Destination = 'London'`)
1 mark for correct ORDER BY clause: - `ORDER BY DelayMinutes DESC` (Must include DESC or DESCENDING)
題目 12 · short_answer
3 分
A toy store uses a database table named `Inventory` to store stock records. The fields in the table are: `ItemID`, `ItemName`, `Quantity`, `Price`, and `Category`.
Write a SQL query to display the `ItemName` and `Price` for all records where the `Category` is 'Games' and the `Price` is less than 20.00. The results must be sorted in alphabetical order of the item names.
查看答案詳解收起答案詳解
解題
To construct the SQL query: 1. Select the required fields: `ItemName` and `Price` from the `Inventory` table: `SELECT ItemName, Price FROM Inventory`. 2. Restrict the records to those where the category is 'Games' and the price is less than 20.00: `WHERE Category = 'Games' AND Price < 20.00`. 3. Sort the final output alphabetically (ascending order, which is the default) by the item names: `ORDER BY ItemName` (or `ORDER BY ItemName ASC`).
Full statement: `SELECT ItemName, Price FROM Inventory WHERE Category = 'Games' AND Price < 20.00 ORDER BY ItemName;`
評分準則
1 mark for correct SELECT and FROM clauses: - `SELECT ItemName, Price FROM Inventory`
1 mark for correct WHERE clause: - `WHERE Category = 'Games' AND Price < 20.00` (Accept `Price < 20`, accept single/double quotes for 'Games', accept conditions in reverse order)
1 mark for correct ORDER BY clause: - `ORDER BY ItemName` or `ORDER BY ItemName ASC`
想知道自己有幾分把握?
Thinka 是 DSE 學生用的 AI 練習應用程式,有無限量練習題、即時自動批改和詳細解題步驟。逾 100,000 名學生用它確認自己真的識,而不只是「以為識」。