An original Thinka practice paper modelled on the structure and difficulty of the Jun 2023 (V1) Cambridge International A Level Computer Science (9618) paper. Not affiliated with or reproduced from Cambridge.
Paper 11: Theory Fundamentals
Answer all questions on the spaces provided in the question paper. Do not use calculators.
20 題目 · 62 分
題目 1 · Short Definition / Explain Terminology
3 分
Explain the purpose and function of a device driver in a computer system.
查看答案詳解收起答案詳解
解題
A device driver is system software that facilitates communication between the operating system and a hardware peripheral. 1. It acts as a translator, converting the operating system's generic input/output instructions into a format or command set that the specific hardware device can execute. 2. It hides the hardware complexities from the OS and user applications. 3. This modularity allows hardware manufacturers to supply drivers for new devices without requiring modifications to the operating system's core kernel code.
評分準則
Award up to 3 marks: - 1 mark: Identify that it acts as an interface/translator between the Operating System (or user applications) and a hardware peripheral. - 1 mark: Explain that it translates generic OS commands/instructions into device-specific commands that the hardware can understand. - 1 mark: Explain that it abstracts the physical hardware layer, allowing the OS to communicate with new/updated hardware without needing to modify the OS itself.
題目 2 · Short Definition / Explain Terminology
3 分
Describe how Carrier Sense Multiple Access with Collision Detection (CSMA/CD) handles a collision on a shared network medium.
查看答案詳解收起答案詳解
解題
CSMA/CD is a media access control method used on Ethernet networks. When two devices transmit simultaneously, a collision occurs. CSMA/CD handles this by: 1. Stopping data transmission immediately upon detecting the collision. 2. Broadcasting a jam signal across the network segment so all other devices are aware of the collision. 3. Using a backoff algorithm where each node waits for a random period of time before attempting to retransmit the frame, reducing the likelihood of a consecutive collision.
評分準則
Award up to 3 marks: - 1 mark: Transmitting device stops transmission immediately upon detecting a collision. - 1 mark: A jam signal is sent/broadcasted to notify all other nodes/devices on the network segment. - 1 mark: Each device waits for a random period of time (using a backoff algorithm) before trying to retransmit.
題目 3 · Short Definition / Explain Terminology
3 分
Explain what is meant by the term 'sampling resolution' in relation to the digital representation of sound.
查看答案詳解收起答案詳解
解題
Sampling resolution, also known as bit depth, refers to the number of bits allocated to represent the amplitude value of each sound sample. For example, a 16-bit sampling resolution allows for \(2^{16} = 65,536\) different discrete amplitude levels. A higher sampling resolution means the digitized sound wave matches the original analog sound wave more accurately, reducing quantization error, though it results in a larger file size.
評分準則
Award up to 3 marks: - 1 mark: Definition: The number of bits used to represent/store each individual sound sample (also called bit depth). - 1 mark: Accuracy: Determines the number of discrete amplitude/volume levels that can be recorded (e.g. \(2^{n}\) levels for \(n\) bits). - 1 mark: Impact: Higher resolution increases the accuracy/dynamic range of the sound (reduces quantization noise) but increases the resulting file size.
題目 4 · Short Definition / Explain Terminology
3 分
Explain the concept of 'referential integrity' in a relational database and how it is enforced.
查看答案詳解收起答案詳解
解題
Referential integrity is a fundamental relational database rule designed to maintain data consistency across linked tables. It ensures that any foreign key field in a child table must contain a value that matches an existing primary key value in the parent table, or the foreign key must be set to null. It prevents the creation of 'orphaned' records. The Database Management System (DBMS) enforces this by blocking attempts to insert invalid foreign keys, or by cascade-deleting/cascade-updating corresponding records when a primary key is changed or removed.
評分準則
Award up to 3 marks: - 1 mark: Concept: Ensures consistency/integrity of data relationships between tables. - 1 mark: Rule: Enforces that a foreign key value in a child table must match an existing primary key value in the parent table (or be null). - 1 mark: Enforcement/Prevention: Prevents orphaned records (e.g. by preventing the deletion of a primary key record while related foreign key records still exist, or using cascade deletes).
題目 5 · Structured DB Mechanics / Normalization Match
4 分
An analyst is designing a database for a medical clinic. They are reviewing several tables to ensure they are normalized correctly.
Match each of the following database scenarios (A to D) with the correct database concept or normalization state from the list: - 1NF (First Normal Form) - 2NF (Second Normal Form) - 3NF (Third Normal Form) - Partial Dependency - Transitive Dependency - Referential Integrity
Scenarios: - Scenario A: A table PatientPrescription has a composite primary key (PatientID, DrugID). The attribute PatientName depends only on PatientID. What is this relationship called? - Scenario B: A table has a single primary key AppointmentID. There are no non-key fields that depend on other non-key fields. Every attribute contains only atomic values. What is the highest normalization state this table is guaranteed to be in? - Scenario C: A developer ensures that every value in the DoctorID column of the Appointments table matches an existing DoctorID in the Doctors table. What database principle is being maintained? - Scenario D: In a table with primary key ClinicID, the attribute ManagerEmail depends on ManagerID, which in turn depends on ClinicID. What is this relationship called?
查看答案詳解收起答案詳解
解題
Scenario A: Since the non-key attribute PatientName depends on only part of the composite primary key (PatientID, DrugID), it is a Partial Dependency. Scenario B: A table with a single primary key cannot contain any partial dependencies, meaning it is automatically in 2NF. Since there are no non-key to non-key dependencies (no transitive dependencies) and all attributes contain atomic values (1NF), it satisfies all conditions for 3NF. Scenario C: Requiring that foreign keys reference a valid, existing primary key in another table is the definition of Referential Integrity. Scenario D: A relationship where a non-key attribute (ManagerEmail) depends on another non-key attribute (ManagerID), which in turn depends on the primary key (ClinicID), is a Transitive Dependency.
評分準則
1 mark for each correct identification: - Scenario A: Partial Dependency (Accept: Partial functional dependency) - Scenario B: 3NF (Accept: Third Normal Form) - Scenario C: Referential Integrity (Reject: Entity integrity) - Scenario D: Transitive Dependency (Accept: Transitive functional dependency)
題目 6 · Structured DB Mechanics / Normalization Match
4 分
A database designer is normalizing a database for a book store. The unnormalised relation is: BookSales(InvoiceNo, CustomerID, CustomerName, CustomerAddress, (BookID, Title, Author, Qty, Price)) Where (BookID, Title, Author, Qty, Price) represents a repeating group.
Identify the correct database term, attribute, or relational schema for each of the following database design steps: 1. Identify the composite primary key of the new transaction details table required to transition this relation to 1NF. 2. To move to 2NF, we must separate customer details into a new table. State this table's schema in standard notation: TableName(PrimaryKey, Attribute1, ...), indicating the primary key clearly. 3. Identify the database term for the relationship where Author is dependent only on BookID in a table with composite key (InvoiceNo, BookID). 4. If a separate 2NF table Book(BookID, Title, PublisherID, PublisherAddress) is kept, where PublisherAddress is functionally dependent on PublisherID, state which normalization form is violated.
查看答案詳解收起答案詳解
解題
1. To remove the repeating group, each repeating entry is matched with the invoice. The unique identifier for each row is the composite key (InvoiceNo, BookID). 2. Customer details depend only on CustomerID, which is a partial key in 1NF. Moving to 2NF requires removing partial dependencies, creating the table Customer(CustomerID, CustomerName, CustomerAddress) where CustomerID is the primary key. 3. Because Author is determined by only BookID (part of the composite key (InvoiceNo, BookID)), this is a Partial Dependency. 4. PublisherAddress is dependent on PublisherID, which is a non-key attribute. This represents a transitive dependency (BookID -> PublisherID -> PublisherAddress) which violates Third Normal Form (3NF).
評分準則
1 mark for each correct point: - Step 1: (InvoiceNo, BookID) (or InvoiceNo and BookID) - Step 2: Customer(CustomerID, CustomerName, CustomerAddress) with CustomerID clearly identified as the primary key - Step 3: Partial Dependency (Accept: Partial functional dependency) - Step 4: 3NF (Accept: Third Normal Form)
題目 7 · Structured DB Mechanics / Normalization Match
4 分
An engineering firm uses a database to track projects, employees, and their roles. The following schema is in 1NF: ProjectAllocation(ProjectID, EmployeeID, ProjectName, ProjectBudget, EmployeeName, Role, HourlyRate) The primary key is the composite key: (ProjectID, EmployeeID).
Match each database design task or observation (1 to 4) to its correct database term, normalization form, or schema definition: 1. In ProjectAllocation, ProjectName and ProjectBudget depend only on ProjectID, which is part of the composite key. State the database term for this relationship. 2. Write the 2NF relation schema (including its primary key) that should be created to hold project details in standard notation. 3. In a 2NF relation Allocation(ProjectID, EmployeeID, Role, HourlyRate), the HourlyRate is functionally determined by the Role (where Role is a non-key attribute). State the database term for this dependency between (ProjectID, EmployeeID) and HourlyRate. 4. State the normalization level of the following set of tables: - Project(ProjectID, ProjectName, ProjectBudget) - Employee(EmployeeID, EmployeeName) - Allocation(ProjectID, EmployeeID, Role) - RoleRate(Role, HourlyRate)
查看答案詳解收起答案詳解
解題
1. ProjectName and ProjectBudget depend on ProjectID, which is only part of the composite key (ProjectID, EmployeeID). This is a Partial Dependency. 2. To remove partial dependency, we extract project attributes into Project(ProjectID, ProjectName, ProjectBudget), where ProjectID is the primary key. 3. Since HourlyRate is determined by Role, and Role is determined by the primary key, HourlyRate is indirectly determined by the primary key via another non-key attribute. This is a Transitive Dependency. 4. These tables are in 3NF (Third Normal Form) because they are in 2NF (no partial dependencies) and all transitive dependencies have been resolved by separating RoleRate into its own table.
評分準則
1 mark for each correct item: - Task 1: Partial Dependency (Accept: Partial functional dependency) - Task 2: Project(ProjectID, ProjectName, ProjectBudget) with ProjectID identified as the primary key - Task 3: Transitive Dependency (Accept: Transitive functional dependency) - Task 4: 3NF (Accept: Third Normal Form)
題目 8 · Short Answer
2 分
Perform the binary addition of the following two 8-bit unsigned binary integers. Show your working and state whether an overflow error has occurred:
01101100 + 10100101
查看答案詳解收起答案詳解
解題
Adding the two binary numbers: 01101100 (108 in denary) + 10100101 (165 in denary) ---------- 100010001 (273 in denary)
Since the correct sum requires 9 bits, it cannot be represented in a standard 8-bit register. Therefore, an overflow error has occurred.
評分準則
1 mark for correct 9-bit binary sum (100010001) or showing correct addition carrying. 1 mark for identifying that an overflow has occurred because the result exceeds the maximum value representable in 8 bits (255).
題目 9 · Short Answer
2 分
Convert the denary value \(-43\) into an 8-bit signed binary integer using two's complement representation. Show your working.
查看答案詳解收起答案詳解
解題
1. Convert the absolute value 43 to binary: \(43 = 32 + 8 + 2 + 1\), which is 00101011 in 8-bit binary. 2. Invert the bits to find the one's complement: 11010100. 3. Add 1 to get the two's complement: 11010101.
評分準則
1 mark for correct binary representation of +43 (00101011) or one's complement (11010100). 1 mark for the correct final 8-bit two's complement binary integer (11010101).
題目 10 · Short Answer
2 分
Convert the denary number 385 into Binary Coded Decimal (BCD) format.
查看答案詳解收起答案詳解
解題
In Binary Coded Decimal (BCD), each individual denary digit is represented by its own 4-bit binary equivalent: - 3 is represented as 0011 - 8 is represented as 1000 - 5 is represented as 0101
Combining these gives: 0011 1000 0101.
評分準則
1 mark for converting at least two of the digits correctly into 4-bit binary. 1 mark for the complete correct 12-bit BCD value (0011 1000 0101 or 001110000101).
題目 11 · Short Answer
2 分
Convert the hexadecimal number BD into an unsigned denary integer. Show your working.
查看答案詳解收起答案詳解
解題
In hexadecimal, the digit B has a value of 11, and the digit D has a value of 13. Using place values: \(11 \times 16^1 + 13 \times 16^0 = 176 + 13 = 189\).
評分準則
1 mark for showing correct working (e.g. converting B to 11 and D to 13, and multiplying by the correct powers of 16). 1 mark for the correct denary answer 189.
題目 12 · Short Answer
2 分
Perform the addition of the following two 8-bit two's complement binary integers. Show your working and state the final 8-bit result:
11111010 + 00001101
查看答案詳解收起答案詳解
解題
Perform binary addition: 11111010 (-6 in denary) + 00001101 (+13 in denary) ---------- (1)00000111 (+7 in denary)
In 8-bit two's complement arithmetic, the carry bit from the most significant bit (MSB) is discarded, leaving the final 8-bit result 00000111.
評分準則
1 mark for showing correct binary addition process with carry-overs shown. 1 mark for the correct final 8-bit binary result (00000111).
題目 13 · short_answer
2 分
A logic circuit has three inputs: \(A\), \(B\), and \(C\). The output \(X\) is produced by an OR gate. The inputs to this OR gate are: - The output of a NAND gate with inputs \(A\) and \(B\). - The output of an XOR gate with inputs \(B\) and \(C\).
Write the Boolean expression that represents this logic circuit. You may use standard algebraic notation or text-based logical operators.
查看答案詳解收起答案詳解
解題
To find the Boolean expression, we break down the logic circuit description: 1. The NAND gate with inputs \(A\) and \(B\) produces the term \(\overline{A \cdot B}\) (or \(\text{NOT}(A \text{ AND } B)\)). 2. The XOR gate with inputs \(B\) and \(C\) produces the term \(B \oplus C\) (or \(B \text{ XOR } C\)). 3. The outputs of these two gates are combined using an OR gate, giving the final expression: \(X = \overline{A \cdot B} + (B \oplus C)\) or \(X = \text{NOT}(A \text{ AND } B) \text{ OR } (B \text{ XOR } C)\).
評分準則
1 mark: Correctly representing the NAND term as \(\overline{A \cdot B}\) (or \(\text{NOT}(A \text{ AND } B)\)). 1 mark: Correctly representing the XOR term combined with the OR gate as \(+ (B \oplus C)\) (or \(\text{OR } (B \text{ XOR } C)\)).
Accept alternative equivalent notations, such as: \(X = \text{NOT}(A \cdot B) + (B \text{ XOR } C)\).
題目 14 · short_answer
2 分
An electronic control system evaluates the Boolean expression: \(X = (A \cdot \overline{B}) + \overline{B \cdot C}\)
Determine the logical value (0 or 1) of the output \(X\) for the following two sets of inputs: 1. \(A = 1, B = 1, C = 1\) 2. \(A = 0, B = 1, C = 0\)
查看答案詳解收起答案詳解
解題
Let us evaluate each scenario step-by-step:
Scenario 1: \(A = 1, B = 1, C = 1\) - Substitute the values into the first term: \(A \cdot \overline{B} = 1 \cdot \overline{1} = 1 \cdot 0 = 0\) - Substitute the values into the second term: \(\overline{B \cdot C} = \overline{1 \cdot 1} = \overline{1} = 0\) - Combine the terms: \(X = 0 + 0 = 0\)
Scenario 2: \(A = 0, B = 1, C = 0\) - Substitute the values into the first term: \(A \cdot \overline{B} = 0 \cdot \overline{1} = 0 \cdot 0 = 0\) - Substitute the values into the second term: \(\overline{B \cdot C} = \overline{1 \cdot 0} = \overline{0} = 1\) - Combine the terms: \(X = 0 + 1 = 1\)
評分準則
1 mark: Correct evaluation showing working or final value of \(X = 0\) for Scenario 1. 1 mark: Correct evaluation showing working or final value of \(X = 1\) for Scenario 2.
題目 15 · Conceptual Architecture Explanation
4 分
Explain the interaction between the Program Counter (PC) and the Memory Address Register (MAR) during the Fetch stage of the Fetch-Execute cycle.
查看答案詳解收起答案詳解
解題
During the Fetch stage, the CPU needs to retrieve an instruction from memory. The Program Counter (PC) keeps track of where that instruction is. Its address is copied to the Memory Address Register (MAR). The PC is then incremented so it is ready for the next cycle. The MAR uses the address bus to point to the exact memory location to begin the read operation.
評分準則
Award 1 mark for each point up to a maximum of 4: - PC holds the address of the next instruction. - Address in PC is copied to the MAR. - PC is incremented (to point to the next instruction). - Address in MAR is sent via the address bus to memory. (Accept equivalent descriptions. Max 4 marks.)
題目 16 · Conceptual Architecture Explanation
4 分
Explain how a network switch directs data packets within a Local Area Network (LAN) and why this makes it more secure and efficient than a network hub.
查看答案詳解收起答案詳解
解題
Unlike a hub which broadcasts incoming packets to every connected port, a switch operates at the Data Link layer and inspects the MAC addresses of incoming frames. It builds a MAC address table matching ports to connected MAC addresses. When a packet arrives, it sends it directly to the designated recipient port. This limits data exposure (security) and avoids unnecessary collision domains and traffic (efficiency).
評分準則
Award 1 mark for each point up to a maximum of 4: - Switch reads the destination MAC address of the packet. - Switch uses a MAC address table / routing table to find the associated destination port. - Data is sent directly to the destination port only (unicast). - This improves efficiency by reducing collision/traffic AND security by preventing other devices from intercepting the data.
題目 17 · Conceptual Architecture Explanation
4 分
Explain how an operating system uses paging to manage physical memory, including the role of the page table.
查看答案詳解收起答案詳解
解題
Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. The OS divides memory into fixed-size chunks: pages for logical memory and frames for physical memory. To keep track of where each page of a process is loaded in physical memory, the OS utilizes a page table. The CPU's memory management unit translates the logical addresses generated by programs into physical addresses using this table.
評分準則
Award 1 mark for each point up to a maximum of 4: - Memory is divided into fixed-size blocks (pages for logical, frames for physical memory). - Pages of a process do not need to be loaded contiguously in physical memory. - The OS maintains a page table to map logical pages to physical frames. - Address translation uses the page table to find the correct physical location.
題目 18 · Conceptual Architecture Explanation
4 分
At the end of a Fetch-Execute cycle, the CPU checks for active interrupts. Explain the sequence of steps the CPU performs if an active interrupt is detected.
查看答案詳解收起答案詳解
解題
When an interrupt is detected at the end of a cycle, the CPU must pause the current execution flow without losing its progress. It saves the context (registers and PC) onto the stack. It then finds the appropriate ISR (Interrupt Service Routine) address, often using an interrupt vector table, and loads this into the PC to begin handling the interrupt. Once completed, a specific instruction restores the saved state from the stack, allowing the CPU to resume exactly where it was interrupted.
評分準則
Award 1 mark for each point up to a maximum of 4: - CPU saves current register state / Program Counter (PC) onto the stack. - CPU identifies interrupt source and looks up the Interrupt Service Routine (ISR) address. - CPU loads ISR address into PC and executes the routine. - Once ISR finishes, CPU restores register state from the stack and resumes previous execution.
題目 19 · Conceptual Architecture Explanation
4 分
Explain the role of a router in directing data packets between different networks.
查看答案詳解收起答案詳解
解題
Routers are essential network devices operating at the Network layer. Their primary purpose is to interconnect different networks (like a home network and the Internet). When a packet arrives, the router examines its IP header to find the destination address. It then consults an internal database called a routing table to find the optimal path for that packet and forwards it to the next network gateway or destination node.
評分準則
Award 1 mark for each point up to a maximum of 4: - Router connects different/multiple networks together. - Router reads/analyzes the destination IP address of incoming packets. - Router maintains and consults a routing table. - Router determines the most efficient path/route and forwards the packet to the next hop.
題目 20 · Conceptual Architecture Explanation
4 分
Explain the role of a device driver and why it is necessary for communication between the Operating System (OS) and a hardware device.
查看答案詳解收起答案詳解
解題
An operating system is designed to be hardware-independent to a large extent. To communicate with a vast array of unique devices (like printers, graphics cards, etc.), it relies on device drivers. The driver translates standardized operating system API calls into the specific low-level binary commands understood by the device. It also manages the flow of data and control signals from the device back to the system. Without drivers, the OS would need to be recompiled or custom-written for every single physical hardware accessory.
評分準則
Award 1 mark for each point up to a maximum of 4: - Device driver acts as a translation layer / interface between the OS and the hardware. - Translates generic OS commands into device-specific binary signals. - Translates device signals / status messages / interrupts back to the OS. - Necessary because hardware components are unique; prevents the OS from needing native code for every physical device on the market.
Paper 21: Fundamental Problem-Solving and Programming Skills
Write clean, structured pseudocode matching the reference insert format. Show appropriate logic for declarations, control structures, and testing.
14 題目 · 61 分
題目 1 · IDE Features & Error Categorization
4 分
An Integrated Development Environment (IDE) provides features to help a programmer debug their code.
Explain how the following two features assist in debugging: 1. Breakpoints 2. Single-stepping
查看答案詳解收起答案詳解
解題
1. Breakpoints: The debugger halts the execution of the program at a predetermined point. The programmer can then use a watch window to view variable values at this specific line to verify if they are correct. 2. Single-stepping: The programmer steps through the code line-by-line. By observing the execution path and variable state changes at each step, they can pinpoint the exact line where the logic deviates from expectations.
評分準則
Maximum 4 marks: - 1 mark for defining Breakpoints (halting/pausing execution at a specific line of code). - 1 mark for explaining how Breakpoints help (allows inspection of variable values/state at that point). - 1 mark for defining Single-stepping (executing the program one line/instruction at a time). - 1 mark for explaining how Single-stepping helps (allows tracking of control flow and pinpointing the exact location where an incorrect state occurs).
題目 2 · IDE Features & Error Categorization
3 分
A programmer writes two code segments. For each segment, state the type of error (Syntax, Runtime, or Logic) that occurs and justify your answer.
Segment 1: `IF Value = 10` ` OUTPUT "Value is ten"` `ENDIF` (Note: The syntax rules of the language require the keyword `THEN` after the condition, which is missing.)
Segment 2: `Average <- Total / Count` (Note: During execution, the variable `Count` has a value of 0, causing the program to crash with a 'Division by Zero' error.)
查看答案詳解收起答案詳解
解題
Segment 1: - Error Type: Syntax error - Justification: The code does not conform to the spelling, grammar, or punctuation rules of the language (missing the 'THEN' keyword). It is detected during compilation/parsing.
Segment 2: - Error Type: Runtime error - Justification: The syntax is correct, so compilation succeeds, but an illegal operation (division by zero) is attempted during execution, leading to an abnormal crash/halt.
評分準則
Maximum 3 marks: - 1 mark: Correctly identifying Segment 1 as a Syntax error and explaining that it violates language grammar rules (preventing translation). - 1 mark: Correctly identifying Segment 2 as a Runtime error and explaining that it happens during execution, causing a crash. - 1 mark: Correctly contrasting the timing of detection (Syntax is pre-execution/at compilation; Runtime is during execution).
題目 3 · practical
3.5 分
An algorithm is designed to process a sequence of positive integers ending with a sentinel value of -1.
The logic is represented by the following flowchart steps: 1. Initialize `Count` to 0, `Sum` to 0. 2. Input the first number into `Num`. 3. Loop while `Num` is not equal to -1: a. If `Num` is even (i.e., `Num MOD 2 = 0` is true), update `Sum <- Sum + Num`. b. Otherwise, update `Count <- Count + 1`. c. Input the next number into `Num`. 4. Output `Sum` and `Count`.
Complete the trace table below for the input sequence: **10, 15, 18, -1**
Let's trace the execution of the algorithm step-by-step:
1. **Initialization**: - `Sum` is set to 0. - `Count` is set to 0.
2. **First iteration**: - `Num` is assigned the first input value: 10. - Since `Num <> -1` is true, enter loop. - Check condition: `10 MOD 2 = 0` is true. - Update `Sum <- Sum + Num` which is `0 + 10 = 10`.
3. **Second iteration**: - `Num` is assigned the next input value: 15. - Check condition: `15 MOD 2 = 0` is false. - Update `Count <- Count + 1` which is `0 + 1 = 1`.
4. **Third iteration**: - `Num` is assigned the next input value: 18. - Check condition: `18 MOD 2 = 0` is true. - Update `Sum <- Sum + Num` which is `10 + 18 = 28`.
5. **Termination**: - `Num` is assigned the next input value: -1. - Since `Num` is -1, the loop terminates. - Output `Sum` (28) and `Count` (1).
Completed trace table structure: - Row 1: Num = (blank), Sum = 0, Count = 0, Output = (blank) - Row 2: Num = 10, Sum = 10, Count = (no change), Output = (blank) - Row 3: Num = 15, Sum = (no change), Count = 1, Output = (blank) - Row 4: Num = 18, Sum = 28, Count = (no change), Output = (blank) - Row 5: Num = -1, Sum = (no change), Count = (no change), Output = 28, 1
評分準則
- 1 mark for correct trace of the `Num` column (including the final -1 sequence value). - 1 mark for correct intermediate updates and final value of the `Sum` column (10 and 28). - 1 mark for correct update and final value of the `Count` column (1). - 0.5 marks for correct final Output values matching the trace.
題目 4 · practical
3.5 分
A flowchart contains a decision process defined by the following sequential operations: 1. Input `BaseSalary` (a real number representing a monthly salary). 2. If `BaseSalary` is strictly greater than 4000: - Set `TaxRate` to 0.25 - Set `Bonus` to 300 3. Otherwise: - Set `TaxRate` to 0.15 - Set `Bonus` to 150 4. Calculate `NetSalary` using the formula: \( NetSalary = BaseSalary - (BaseSalary \times TaxRate) + Bonus \) 5. Output `NetSalary`.
Write 9618 pseudocode that corresponds to this flowchart logic. You must include appropriate variable declarations.
查看答案詳解收起答案詳解
解題
To implement this logic in 9618 Pseudocode:
1. Declare all variables with correct types using `DECLARE : `. 2. Read the input with `INPUT`. 3. Execute the conditional check with an `IF ... THEN ... ELSE ... ENDIF` block. 4. Perform the assignment utilizing the standard assignment operator `<-`. 5. Print the output using `OUTPUT`.
```pseudocode DECLARE BaseSalary : REAL DECLARE TaxRate : REAL DECLARE Bonus : INTEGER DECLARE NetSalary : REAL
- 1 mark: Correct declaration of all variables (`BaseSalary`, `TaxRate`, `NetSalary` as `REAL`, and `Bonus` as `INTEGER` or `REAL`). - 1 mark: Correct selection structure syntax with `IF`, `THEN`, `ELSE`, and `ENDIF` keywords in uppercase. - 1 mark: Correct calculation of `NetSalary` using standard mathematical operators and the `<-` assignment symbol. - 0.5 marks: Correct usage of `INPUT` and `OUTPUT` statements.
題目 5 · structured
3 分
A programmer is designing a program to store data about video games in a collection. Each game has a unique code GameID (e.g., 'G105'), a name Title (e.g., 'Space Quest'), and a price Price (e.g., 49.99). Write pseudocode to: 1. Define a user-defined record type named Game. 2. Declare a 1D array named Inventory that can store up to 100 Game records, indexed from 1.
查看答案詳解收起答案詳解
解題
To define a record in Cambridge pseudocode, the TYPE ... ENDTYPE construct is used. Inside, the fields must be declared with their types: GameID as STRING, Title as STRING, and Price as REAL. The array declaration uses DECLARE : ARRAY[:] OF . Thus, DECLARE Inventory : ARRAY[1:100] OF Game correctly declares the collection.
評分準則
1 mark: Correct TYPE Game ... ENDTYPE structure with all three fields (GameID : STRING, Title : STRING, Price : REAL) declared with appropriate types. 1 mark: Correct declaration of the array identifier and bounds ARRAY[1:100]. 1 mark: Specifying the array base type as Game.
題目 6 · structured
3 分
An array of records is defined using the following pseudocode:
TYPE Participant DECLARE Name : STRING DECLARE Active : BOOLEAN ENDTYPE
DECLARE Club : ARRAY[1:50] OF Participant
Write the pseudocode statement(s) to: 1. Assign the value TRUE to the Active status of the 25th participant in the Club array. 2. Print the Name of the last participant in the array.
查看答案詳解收起答案詳解
解題
To reference a field within a record that is stored inside an array, the array index is supplied first, followed by a dot operator, and then the field name. 1. The 25th participant is accessed using Club[25]. To set their Active field to TRUE, use: Club[25].Active <- TRUE. 2. The last participant is at index 50, so they are accessed using Club[50]. Their name is printed using OUTPUT Club[50].Name.
評分準則
1 mark: Correct assignment to Active of index 25: Club[25].Active <- TRUE (Accept standard assignment operator '=' instead of '<-'). 1 mark: Correct access of the last element's name using index 50: Club[50].Name. 1 mark: Use of a standard output command such as OUTPUT or PRINT with the correct field reference.
Write a pseudocode function `ExtractScores` that takes a string `CSVLine` containing exactly 5 integer scores separated by semi-colons (for example, `"85;92;78;90;88"`).
The function must parse these scores and store them in a 1D array `ScoreArray` of 5 integers, which is passed by reference.
The function must return `TRUE` if all 5 scores are successfully parsed and each score is in the range 0 to 100 inclusive. It must return `FALSE` if any score is outside this range, or if the string does not contain exactly 5 scores.
You can assume standard string manipulation functions: - `LENGTH(s : STRING) RETURNS INTEGER` - `MID(s : STRING, start : INTEGER, length : INTEGER) RETURNS STRING` (index starts at 1) - `TONUM(s : STRING) RETURNS INTEGER` (converts numeric string to integer)
查看答案詳解收起答案詳解
解題
The function processes the string character-by-character to locate the delimiters (`;`). An extra delimiter is appended to the string to ensure the final token is parsed correctly. - It tracks the `StartPos` of each substring. - For each delimiter encountered, it extracts the substring, converts it to an integer, and checks if it falls within the range [0, 100]. - It stores valid values into the correct index of `ScoreArray`. - Finally, it validates that exactly 5 values were parsed and all of them were within range, returning `TRUE` or `FALSE` accordingly.
評分準則
1 mark: Correct function header with correct parameters (BYREF for array) and BOOLEAN return type. 1 mark: Appending a delimiter or handling the end of string parsing accurately. 1 mark: Loop over the string characters using `MID` to identify ';' delimiters. 1 mark: Use of `TONUM` to convert substrings to integers and assignment to the correct array index. 1 mark: Logic to check if all parsed scores are between 0 and 100 (inclusive). 1 mark: Check that exactly 5 elements are processed and return appropriate BOOLEAN value.
An array of strings `Queue` contains some elements representing names, and others representing empty slots (indicated by an empty string `""`).
Write a pseudocode procedure `ShiftQueue` that takes two parameters: - `Queue`: a 1D array of strings (passed by reference) - `MaxSize`: the integer size of the array
The procedure must shift all non-empty elements to the left to close any empty slots (retaining their relative order), and fill the remaining rightmost elements with `""`.
For example, if `Queue` initially contains: `["", "Alice", "Bob", "", "Charlie", ""]` and `MaxSize` is 6, after calling `ShiftQueue`, the array must contain: `["Alice", "Bob", "Charlie", "", "", ""]`.
查看答案詳解收起答案詳解
解題
The algorithm uses two pointers: `ReadPointer` scan-steps through the array from left to right, and `WritePointer` tracks where the next non-empty value should be placed. 1. For every non-empty element found at `Queue[ReadPointer]`, the value is copied to `Queue[WritePointer]` and `WritePointer` is incremented. 2. Once all elements are read, the remaining indices from `WritePointer` to `MaxSize` are overwritten with empty strings (`""`) to clear the trailing duplicates/garbage.
評分準則
1 mark: Correct procedure header including BYREF for `Queue` parameter. 1 mark: Use of a write-pointer initialized to the start index (1). 1 mark: Loop through the array from 1 to `MaxSize` using a read-pointer. 1 mark: Correct conditional statement to filter out empty strings (`<> ""`). 1 mark: Correct shifting assignment `Queue[WritePointer] <- Queue[ReadPointer]` and incrementing `WritePointer`. 1 mark: Post-shifting loop/fill operation to set all remaining indices to `""`.
A teacher stores student attendance in a 2D array `Attendance` of size 30 rows by 5 columns, representing 30 students and 5 school days. `Attendance[R, C]` is either `TRUE` (present) or `FALSE` (absent).
Write a pseudocode function `PerfectAttendance` that takes: - `Attendance`: the 2D array of BOOLEAN values (passed by value) - `PerfectStudents`: a 1D array of 30 integers (passed by reference)
The function must search the `Attendance` array and identify the row index (1 to 30) of any student who was present on all 5 days. These row indices must be stored in the `PerfectStudents` array starting from index 1.
The function must return the total number of students with perfect attendance.
查看答案詳解收起答案詳解
解題
The function initializes a counter `PerfectCount` to 0. It loops through each student (row 1 to 30) and initializes a boolean flag `IsPerfect` to `TRUE`. A nested loop checks the attendance of each day (column 1 to 5). If any day is `FALSE`, the student does not have perfect attendance, and `IsPerfect` is updated to `FALSE`. After checking all 5 days for a student, if `IsPerfect` is still `TRUE`, `PerfectCount` is incremented, and the row index is saved into `PerfectStudents` at index `PerfectCount`.
評分準則
1 mark: Correct function header with correct parameters, modes (BYREF/BYVAL), and INTEGER return type. 1 mark: Initializing counter variable to 0 and loop structure to iterate rows from 1 to 30. 1 mark: Correct inner loop to iterate columns from 1 to 5. 1 mark: Logic to check if any entry is FALSE and update a flag variable. 1 mark: Storing the correct row index at the correct `PerfectCount` position in the `PerfectStudents` array. 1 mark: Returning the total counter after outer loop completion.
題目 10 · Algorithm Design and Problem-solving
7 分
A sequential text file Stock.txt contains stock level information for a retail store. The data for each stock item is stored across three consecutive lines: - Line 1: Item ID (a string, e.g., "XY1054") - Line 2: Quantity in stock (an integer) - Line 3: Unit Price (a real number)
An Item ID must be validated before the stock record is processed. A valid Item ID must meet the following rules: - It must be exactly 6 characters long. - The first two characters must be uppercase alphabetic characters ('A' to 'Z'). - The remaining four characters must be digits ('0' to '9').
Write pseudocode for a function CalculateTotalValue which: - Takes an integer parameter MinStock representing a threshold quantity. - Reads all records from Stock.txt. - Validates the Item ID for each record. - If the Item ID is valid and the Quantity is greater than or equal to MinStock, calculates the total stock value for that item (Quantity multiplied by Unit Price) and adds it to a running total. - Closes the file and returns the accumulated total value.
查看答案詳解收起答案詳解
解題
The function opens Stock.txt in read mode and processes each item by reading exactly three lines per loop iteration: ItemID, Quantity, and UnitPrice. Inside the loop, validation checks that the ItemID has a length of 6. A loop from 1 to 2 checks that the first two characters are in the range 'A' to 'Z'. Another loop from 3 to 6 checks that the next four characters are in the range '0' to '9'. If the item passes validation and its quantity is at least MinStock, its value (Quantity * UnitPrice) is added to the running TotalValue. After the file is processed fully, the file is closed and the total value is returned.
評分準則
- 1 mark: Correct function header with an integer parameter and REAL return type, and a correct RETURN statement. - 1 mark: Correct file opening and closing logic using "Stock.txt" in READ mode. - 1 mark: Correct loop using NOT EOF("Stock.txt") and reading three consecutive variables (ItemID, Quantity, UnitPrice) in the correct order. - 1 mark: Checking length equals 6 and validating that characters 1-2 are uppercase alphabetic ('A'-'Z'). - 1 mark: Validating that characters 3-6 are numeric digits ('0'-'9'). - 1 mark: Logical check combining the ItemID validity and testing if Quantity >= MinStock. - 1 mark: Calculating of the stock item value (Quantity * UnitPrice) and adding it to the running accumulator (initialized to 0.0).
題目 11 · Algorithm Design and Problem-solving
7 分
A sequential text file Members.txt stores information about members of a sports club. Each member's record is stored on a single line as a fixed-width string of exactly 15 characters, structured as follows: - Characters 1 to 7: Member ID (e.g., "MBR8904") - Characters 8 to 11: Birth Year (e.g., "1998") - Character 12: Membership Level (either 'G' for Gold, 'S' for Silver, or 'B' for Bronze) - Characters 13 to 15: Status (either "ACT" for Active or "INA" for Inactive)
A member record is considered valid if and only if it meets all the following criteria: - The Member ID starts with "MBR" followed by exactly four digits ('0' to '9'). - The Birth Year consists only of digits and is between 1940 and 2010 inclusive. - The Membership Level is one of the characters: 'G', 'S', or 'B'. - The Status is either "ACT" or "INA".
Write pseudocode for a function CountValidGoldMembers which: - Takes no parameters. - Reads all records from Members.txt. - Validates each record according to the rules above. - Counts how many valid members have a Membership Level of 'G' (Gold) and a Status of "ACT" (Active). - Closes the file and returns the total count as an integer.
查看答案詳解收起答案詳解
解題
The function opens Members.txt in read mode. It iterates through the file, reading each line into MemberLine. Only lines of exactly length 15 are parsed. Substrings are extracted using MID(). The MemberID must start with 'MBR' and the next four characters must be verified as digits. The BirthYearStr must be verified as 4 digits before calling STR_TO_NUM to prevent runtime errors, and the resulting integer must be verified within the 1940-2010 range. The Level must be 'G', 'S', or 'B' and Status must be 'ACT' or 'INA'. Finally, if the record is valid and Level is 'G' and Status is 'ACT', the Count is incremented. The file is closed at the end, and Count is returned.
評分準則
- 1 mark: Correct function header with no parameters and returns INTEGER, and correct initialization and return of Count. - 1 mark: Opening and closing Members.txt correctly, and looping with NOT EOF("Members.txt") and reading lines into a string variable. - 1 mark: Extracting substrings correctly using MID() based on the specified character boundaries. - 1 mark: Validating that Member ID starts with "MBR" and has 4 numeric digits. - 1 mark: Validating Birth Year is numeric, converting it to an integer, and confirming it lies in the range 1940 to 2010 inclusive. - 1 mark: Validating Level is ('G', 'S', 'B') and Status is ("ACT", "INA"). - 1 mark: Incrementing the count only when all validations pass AND Level is "G" and Status is "ACT".
題目 12 · structured
3 分
A software developer is using a top-down integration testing approach to test a program consisting of a main module, ProcessOrder, which calls a lower-level module, CalculateTax. At this stage of development, CalculateTax has not yet been written. Explain how a stub is used to test the ProcessOrder module in this scenario.
查看答案詳解收起答案詳解
解題
In top-down testing, higher-level modules are tested before lower-level modules are fully developed. To test ProcessOrder: 1. A stub is created to stand in for the unfinished CalculateTax module. 2. When ProcessOrder executes, it calls the CalculateTax stub. 3. The stub bypasses complex logic and returns a static or predictable value (e.g., always returning 5.00) back to ProcessOrder, allowing the developer to verify if ProcessOrder handles the returned value correctly.
評分準則
1 mark: State that a stub acts as a temporary/simplified dummy module replacing CalculateTax. 1 mark: State that ProcessOrder calls the stub (allowing ProcessOrder to be executed/tested before CalculateTax is coded). 1 mark: State that the stub returns a pre-determined/hardcoded/fixed value to the calling module to verify its control logic.
題目 13 · structured
3 分
A validation function ValidateAge(Age : INTEGER) returns TRUE if the input Age is in the valid range of 18 to 65 inclusive, and FALSE otherwise. State three distinct test cases that would be used to perform Boundary Value Analysis (BVA) specifically around the lower limit of the range. For each test case, state the input value and the expected outcome.
查看答案詳解收起答案詳解
解題
Boundary Value Analysis (BVA) tests the exact boundary, one unit below the boundary, and one unit above the boundary. For a lower limit of 18 (inclusive): - Just below the boundary: 17 (expected output: FALSE) - On the boundary: 18 (expected output: TRUE) - Just above the boundary: 19 (expected output: TRUE)
評分準則
1 mark: Input value 17 with expected outcome FALSE / Invalid. 1 mark: Input value 18 with expected outcome TRUE / Valid. 1 mark: Input value 19 with expected outcome TRUE / Valid.
題目 14 · structured
3 分
A software company is developing a mobile application where the client's requirements are expected to change frequently throughout the development cycle. Explain three reasons why an Agile software development model is more suitable than a traditional Waterfall model for this project.
查看答案詳解收起答案詳解
解題
The Agile model is designed for flexibility and client collaboration, whereas Waterfall is rigid and sequential: - Iterative Nature: Agile breaks the project into small sprints, meaning changes can be introduced dynamically between cycles. - Client Involvement: The client regularly reviews working prototypes, helping them refine their requirements as they see the product take shape. - Adaptability to Change: In Waterfall, making changes late in the lifecycle is difficult and expensive because testing only occurs after implementation. Agile accommodates changes throughout.
評分準則
1 mark: Identify that Agile is iterative/incremental, allowing requirements to be updated/added during development (unlike Waterfall where they are frozen early on). 1 mark: Mention frequent client feedback / regular sprint reviews which help steer the development dynamically. 1 mark: Explain that functional prototypes are delivered regularly, reducing the risk of building software that does not meet the user's changing needs.
想知道自己有幾分把握?
Thinka 是 DSE 學生用的 AI 練習應用程式,有無限量練習題、即時自動批改和詳細解題步驟。逾 100,000 名學生用它確認自己真的識,而不只是「以為識」。