An original Thinka practice paper modelled on the structure and difficulty of the May 2024 SL (TZ1) IB Diploma Programme Computer Science paper. Not affiliated with or reproduced from IB.
Section A
Answer all questions. Short-answer and theoretical questions testing core content across topics 1, 2, and 3.
15 Question · 25 marks
Question 1 · short-answer
1.5 marks
Outline one social or ethical issue associated with the implementation of a new computerized booking system in a medical clinic.
Show answer & marking schemeHide answer & marking scheme
Worked solution
One major ethical issue is data privacy. During the migration of sensitive medical history to a new system, or through insecure system design, unauthorized parties might access patient data. A social issue is staff redundancy, where automated booking reduces the need for manual receptionist work, causing job loss or requiring significant retraining.
Marking scheme
Award [1.0 mark] for identifying a valid social or ethical issue (e.g., job redundancy, data privacy, digital exclusion, or retraining stress). Award [0.5 marks] for explaining its impact clearly in the context of the medical clinic.
Question 2 · short-answer
1.5 marks
State the function of the Program Counter (PC) in the Central Processing Unit (CPU) during the fetch-execute cycle.
Show answer & marking schemeHide answer & marking scheme
Worked solution
The Program Counter (PC) is a dedicated CPU register. Its main function is to hold the memory address of the next instruction that needs to be retrieved from main memory (RAM). Once that instruction is fetched, the PC automatically increments to point to the address of the succeeding instruction.
Marking scheme
Award [1.0 mark] for stating that the PC holds the address of the next instruction to be fetched. Award [0.5 marks] for stating that it increments/updates after the instruction is fetched.
Question 3 · short-answer
1.5 marks
Identify the primary role of a router in data transmission across wide area networks.
Show answer & marking schemeHide answer & marking scheme
Worked solution
A router acts as a node connecting separate computer networks. It analyzes incoming packet headers to determine the destination IP address, consults its internal routing table, and forwards the packet to the next optimal hop to reach its destination.
Marking scheme
Award [1.0 mark] for identifying that a router forwards data packets between different networks. Award [0.5 marks] for identifying that it determines the optimal routing path or reads IP address headers.
Question 4 · short-answer
1.5 marks
Outline the concept of abstraction as a computational thinking tool in software development.
Show answer & marking schemeHide answer & marking scheme
Worked solution
In computational thinking, abstraction involves simplifying complex real-world situations by extracting the core elements and hiding irrelevant details. This allows programmers to model a system using generalized structures (like classes or functions) without being bogged down by low-level technicalities.
Marking scheme
Award [1.0 mark] for defining abstraction as removing unnecessary details/reducing complexity. Award [0.5 marks] for stating its purpose (e.g., helping developers focus on core ideas, or facilitating general model creation).
Question 5 · short-answer
1.5 marks
Identify the difference between alpha testing and beta testing in terms of who performs the testing.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Alpha testing is an internal test conducted near the end of development. It is performed by the software company's own employees (developers, QA testers) in a controlled laboratory environment. Beta testing is the external testing phase, where a pre-release version of the software is distributed to a select group of target end-users to find real-world bugs before final release.
Marking scheme
Award [0.75 marks] for correctly identifying that alpha testing is done internally by the development/QA team. Award [0.75 marks] for correctly identifying that beta testing is done externally by actual target users.
Question 6 · short-answer
1.5 marks
Outline why cache memory is used in a computer system despite its high cost per megabyte.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Although RAM is cheaper and larger, it operates much slower than the CPU. Cache memory (SRAM) is integrated directly into or very near the processor core. By copying frequently or recently used instructions and data into cache, the CPU avoids wasting clock cycles waiting for data to load from RAM, significantly speeding up overall execution.
Marking scheme
Award [1.0 mark] for identifying cache as extremely high-speed memory that stores frequently/recently used data. Award [0.5 marks] for explaining that it minimizes the CPU access delay associated with reading from main memory (RAM).
Question 7 · short-answer
1.5 marks
State the primary purpose of the Domain Name System (DNS) on the internet.
Show answer & marking schemeHide answer & marking scheme
Worked solution
The DNS serves as the directory for the internet. Humans use alphanumeric domain names because they are easier to remember, but network devices communicate using numeric IP addresses. The DNS maps these domains to their corresponding IP addresses, allowing browsers to locate and connect to servers.
Marking scheme
Award [1.0 mark] for stating that DNS translates domain names to IP addresses (or vice versa). Award [0.5 marks] for explaining that this is necessary because network equipment requires numerical IP addresses to route requests, while humans require mnemonic names.
Question 8 · short-answer
1.5 marks
Outline the difference between a variable and a constant in a computer program.
Show answer & marking schemeHide answer & marking scheme
Worked solution
A variable is a named memory location used to store data that is subject to change as the program runs (e.g., a counter). A constant is also a named location, but its value is immutable once set (e.g., the value of \(\pi\) as 3.14159), preventing accidental modification during runtime.
Marking scheme
Award [0.75 marks] for stating that a variable's value can change during program execution. Award [0.75 marks] for stating that a constant's value remains fixed/unchanged once defined.
Question 9 · Outline
1.5 marks
Outline one disadvantage of a direct changeover (immediate cutover) system installation method.
Show answer & marking schemeHide answer & marking scheme
Worked solution
In a direct changeover, the old system is completely discarded and replaced by the new system at a specific time. The primary disadvantage is that if the new system contains critical bugs or fails, there is no alternative system running to take over (fallback). This can result in complete operational downtime, lost productivity, and potential data corruption or loss because the old system is no longer available to resume tasks.
Marking scheme
[1 mark] for identifying the core disadvantage (e.g., lack of a backup/fallback system if the new system fails). [0.5 marks] for outlining the consequence of this failure (e.g., operational downtime, business disruption, or loss of data).
*Acceptable alternatives:* No period of dual-running to compare outputs, high user stress due to sudden transition.
Question 10 · Outline
1.5 marks
Outline the role of a tunneling protocol in a Virtual Private Network (VPN).
Show answer & marking schemeHide answer & marking scheme
Worked solution
Tunneling is a mechanism used in VPNs to securely transmit private data over a public infrastructure like the Internet. It works by encapsulating (wrapping) the original private data packet inside another outer packet (the tunnel packet). The outer packet protects the original data's headers and payload, and routing is performed based on the outer packet's headers. This creates a virtual private path through public networks, preventing unauthorized interception and maintaining data confidentiality.
Marking scheme
[1 mark] for explaining the concept of encapsulation (wrapping private packets inside public/transit packets). [0.5 marks] for describing the purpose or effect (ensuring secure transit/confidentiality over an unsecure public network/the Internet).
Question 11 · Describe / Distinguish
2 marks
Distinguish between a direct changeover and a parallel running installation method when implementing a new computer system.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Under a direct changeover, the old system is completely discarded and the new system is introduced at a specific point in time. This is high risk because if the new system fails, there is no immediate backup, but it is cheap and fast. Under parallel running, the old and new systems are run side-by-side for a period of time. This is low risk because the old system can be used if the new one fails, but it is expensive as it requires extra labor and resources to run both systems.
Marking scheme
Award [1] mark for identifying a key feature of direct changeover (e.g., immediate swap, high risk, or low cost). Award [1] mark for identifying a key feature of parallel running (e.g., simultaneous execution, low risk, or high cost/resource usage) to show distinction.
Question 12 · Describe / Distinguish
2 marks
Describe the role of the Program Counter (PC) register in the machine instruction cycle.
Show answer & marking schemeHide answer & marking scheme
Worked solution
The Program Counter (PC) is a dedicated register within the CPU. Its primary role is to store the address of the next instruction that needs to be fetched from RAM. During the fetch phase of the machine cycle, this address is copied to the Memory Address Register (MAR), and the PC is subsequently updated/incremented to hold the address of the next sequential instruction, ensuring continuous execution.
Marking scheme
Award [1] mark for stating that it holds the memory address of the next instruction to be fetched/executed. Award [1] mark for describing how it increments/updates during or after the fetch cycle to ensure sequential execution.
Question 13 · Describe / Distinguish
2 marks
Distinguish between the roles of a Media Access Control (MAC) address and an Internet Protocol (IP) address in data transmission.
Show answer & marking schemeHide answer & marking scheme
Worked solution
A MAC address is burned into the Network Interface Card (NIC) at manufacture and is globally unique, serving to identify physical devices within a local network segment (Data Link Layer). On the other hand, an IP address is dynamically or statically assigned by software to represent a device's current logical location on a larger network, allowing routers to forward packets across different subnetworks (Network Layer).
Marking scheme
Award [1] mark for describing the MAC address (e.g., physical/hardware, permanent, local network communication). Award [1] mark for describing the IP address (e.g., logical/software, dynamic/changeable, routing across global/different networks).
Question 14 · Describe / Distinguish
2 marks
Describe how attenuation can cause data loss during transmission over a physical medium.
Show answer & marking schemeHide answer & marking scheme
Worked solution
As an electrical or optical signal travels along a physical medium such as a copper cable, it encounters resistance, causing the signal to lose strength or amplitude over distance (attenuation). If the signal becomes too weak before reaching its destination, it may drop below the minimum threshold required for the receiving device to decode it correctly, resulting in data loss or packet corruption.
Marking scheme
Award [1] mark for defining attenuation as the loss of signal strength/amplitude over distance. Award [1] mark for explaining how this degradation prevents the receiver from correctly interpreting/decoding the transmitted data, leading to packet loss or corruption.
Question 15 · Describe / Distinguish
2 marks
Distinguish between alpha testing and beta testing.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Alpha testing is the initial phase of software testing performed in-house by software developers and internal quality assurance (QA) teams to identify major bugs before the product is exposed to the public. Beta testing occurs later in the development cycle, where a pre-release version of the software is distributed to a limited group of actual end-users who test it in real-world scenarios, providing feedback on usability and remaining bugs.
Marking scheme
Award [1] mark for identifying that alpha testing is internal, performed by developers/QA in a controlled environment. Award [1] mark for identifying that beta testing is external, performed by target end-users in their own real-world environments.
Section B
Answer all questions. Three multi-part structured questions testing deeper conceptual understanding and algorithm design.
14 Question · 45 marks
Question 1 · structured
3 marks
A school network experiences heavy concurrent usage during break times when students browse the internet. Explain why packet switching is more efficient than circuit switching in this environment.
Show answer & marking schemeHide answer & marking scheme
Worked solution
In a packet-switched network, data is broken into smaller packets that are sent independently over shared communication channels. This contrasts with circuit switching, which requires a dedicated end-to-end connection for the duration of the communication session.
Key reasons for efficiency in high-concurrency environments: 1. Shared Resources: Multiple users' packets can interleave on the same physical link, maximizing bandwidth utilization. 2. No Idle Resource Waste: Unlike circuit switching where a dedicated line remains idle when no data is being sent, packet switching only consumes bandwidth when data is actually transmitted. 3. Dynamic Routing: If a particular route or node becomes congested, routers can dynamically redirect packets through less busy paths.
Marking scheme
Award up to [3] marks as follows: - [1 mark] for explaining that packet switching allows communication lines to be shared among multiple users simultaneously (avoiding dedicated lines). - [1 mark] for identifying that packet-switched networks utilize bandwidth more efficiently because they do not waste resources during idle periods/silence. - [1 mark] for explaining that packets can be dynamically rerouted around congested or failed nodes, which keeps traffic flowing during peak times.
Question 2 · structured
3 marks
Identify three essential functions performed by a router in a local area network (LAN) connected to the internet.
Show answer & marking schemeHide answer & marking scheme
Worked solution
A router acts as a crucial intersection point between different networks. Its primary functions include: 1. Routing: Analyzing the destination IP address of incoming packets and using routing tables to forward them along the most efficient path. 2. Network Address Translation (NAT): Enabling multiple devices on the LAN to share a single public IP address when communicating with the internet. 3. IP Address Allocation (DHCP): Automatically assigning local IP addresses to devices when they connect to the local network to prevent address conflicts.
Marking scheme
Award [1 mark] for each valid function identified, up to a maximum of [3 marks]. - Routing/forwarding packets based on IP addresses. - Performing Network Address Translation (NAT) to bridge local and external networks. - Distributing IP addresses dynamically (DHCP). - Acting as a default gateway/firewall to filter traffic between the LAN and the WAN.
Question 3 · structured
3 marks
Describe the role of a gateway when connecting two heterogeneous networks.
Show answer & marking schemeHide answer & marking scheme
Worked solution
A gateway serves as a entry/exit point for a network and bridges two systems that use different communication protocols or data formats.
Its roles include: 1. Protocol Translation: It converts the packet formatting, address structures, and command sets from one protocol suite (e.g., AppleTalk or IPX) to another (e.g., TCP/IP). 2. Multi-Layer Functionality: Unlike routers which operate primarily at the Network layer (Layer 3), a gateway often works up to the Application layer (Layer 7) to translate the payload data itself. 3. Interface Boundary: It acts as the boundary node, ensuring that external traffic conforms to the standards of the receiving network before forwarding it.
Marking scheme
Award up to [3] marks as follows: - [1 mark] for identifying that a gateway acts as an interface/boundary between networks with different, incompatible protocols. - [1 mark] for explaining that it translates/converts protocol formats, headers, or data structures from one network type to another. - [1 mark] for stating that it operates across multiple layers of the OSI model (up to the application layer) to ensure end-to-end compatibility.
Question 4 · structured
3 marks
Compare fiber optic cables and unshielded twisted pair (UTP) copper cables in terms of bandwidth, transmission range, and susceptibility to electromagnetic interference (EMI).
Show answer & marking schemeHide answer & marking scheme
Worked solution
The two transmission media compare as follows: 1. Bandwidth: Fiber optic cables provide extremely high bandwidth (gigabits to terabits per second) because light has a much higher frequency than electricity. UTP cables are limited to lower maximum speeds (typically up to \(10\text{ Gbps}\) depending on the category). 2. Transmission Range: Fiber optic cables can transmit data over tens of kilometers without needing repeaters due to low attenuation. UTP cables are physically limited to a maximum run of about \(100\text{ meters}\) before attenuation degrades the signal. 3. EMI Susceptibility: Fiber optic cables use glass/plastic fibers to transmit light, making them completely immune to electromagnetic interference (EMI). UTP cables use copper wires which carry electrical currents, making them prone to cross-talk and external EMI from power lines or machinery.
Marking scheme
Award up to [3] marks as follows: - [1 mark] for contrasting bandwidth (fiber optic has significantly higher bandwidth/speeds than UTP). - [1 mark] for contrasting transmission range (fiber optic can transmit over very long distances without degradation, whereas UTP is limited to approximately \(100\text{ m}\)). - [1 mark] for contrasting EMI susceptibility (fiber optic is completely immune because it uses light, whereas UTP is susceptible because it uses electrical signals).
Question 5 · structured
3 marks
Explain the necessity of having standardized protocols for data packet transmission across the internet.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Without standardized protocols, internet communication would be impossible because devices would lack a common "language" to coordinate transmissions.
Key reasons for protocols include: 1. Interoperability: Ensuring devices built by different companies (e.g., Apple, Microsoft, Cisco) can understand the structured format of incoming packets. 2. Error Handling & Flow Control: Implementing standardized algorithms (like TCP's sliding window) to prevent network congestion, detect transmission errors (using checksums), and request retransmission of dropped packets. 3. Sequencing and Reassembly: Providing rules to label packets with sequence numbers so the destination device can reassemble them in the correct order, even if they arrive out of sequence.
Marking scheme
Award up to [3] marks as follows: - [1 mark] for explaining that protocols provide interoperability/common standards allowing heterogeneous devices from different manufacturers to communicate. - [1 mark] for explaining that they define rules for formatting, packet sequencing, and reassembly so data can be rebuilt correctly. - [1 mark] for explaining that they manage reliability features such as error detection (checksums), retransmission of lost packets, or flow control.
Question 6 · Logic Gates & Algorithm Pseudocode
3 marks
An automated greenhouse ventilation system controls a fan (\(F\)). The fan turns on (\(F = 1\)) under either of the following conditions: 1. The temperature is high (\(T = 1\)) AND the humidity is high (\(H = 1\)). 2. The manual override switch is activated (\(M = 1\)).
(a) Write the Boolean expression for \(F\). (b) Identify the two types of logic gates (excluding any NOT gates) and the quantity of each required to implement this unsimplified expression directly.
Show answer & marking schemeHide answer & marking scheme
Worked solution
To represent the conditions: - Temperature is high AND humidity is high is written as: \(T \text{ AND } H\) (or \(T \cdot H\)). - Either that condition OR the manual override switch is activated is written as: \((T \text{ AND } H) \text{ OR } M\) (or \(T \cdot H + M\)).
To implement this unsimplified expression directly, we need: - One 2-input AND gate (to compute \(T \text{ AND } H\)). - One 2-input OR gate (to compute the result of the AND operation OR \(M\)).
Marking scheme
Award 1 mark for the correct Boolean expression: \(F = (T \cdot H) + M\) (accept equivalent logic notation such as \(F = (T \text{ AND } H) \text{ OR } M\)). Award 1 mark for correctly identifying 1 AND gate. Award 1 mark for correctly identifying 1 OR gate.
Question 7 · Logic Gates & Algorithm Pseudocode
3 marks
A programmer is writing an algorithm to count how many elements in a 1D array of integers, `NUMBERS`, are strictly greater than a threshold value, `LIMIT`.
Complete the following pseudocode by identifying the correct expressions for the blanks [1], [2], and [3].
``` COUNT = 0 loop I from 0 to NUMBERS.length - 1 if [1] then [2] end if end loop output [3] ```
Show answer & marking schemeHide answer & marking scheme
Worked solution
To solve this problem, we need to complete the three placeholders: 1. The condition `[1]` needs to check if the current element of the array at index `I` is strictly greater than the threshold `LIMIT`. Thus, `[1]` is `NUMBERS[I] > LIMIT`. 2. When the condition is true, the counter `COUNT` must be incremented. Thus, `[2]` is `COUNT = COUNT + 1`. 3. After the loop completes, the total count needs to be displayed. Thus, `[3]` is `COUNT`.
Marking scheme
Award 1 mark for each correct blank: - [1]: `NUMBERS[I] > LIMIT` (accept equivalent correct syntax) - [2]: `COUNT = COUNT + 1` (accept `COUNT = COUNT + 1` or `COUNT++` or `COUNT = COUNT + 1`) - [3]: `COUNT`
Question 8 · Logic Gates & Algorithm Pseudocode
3 marks
Consider the Boolean expression: \(X = \text{NOT}(A \text{ AND } B) \text{ OR } (B \text{ XOR } C)\)
Determine the output value of \(X\) for the following three input scenarios: 1. \(A = 1, B = 1, C = 1\) 2. \(A = 0, B = 1, C = 0\) 3. \(A = 1, B = 0, C = 1\)
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let's evaluate each scenario step-by-step:
1. For \(A = 1, B = 1, C = 1\): - \(A \text{ AND } B = 1 \text{ AND } 1 = 1\) - \(\text{NOT}(A \text{ AND } B) = \text{NOT}(1) = 0\) - \(B \text{ XOR } C = 1 \text{ XOR } 1 = 0\) - \(X = 0 \text{ OR } 0 = 0\)
2. For \(A = 0, B = 1, C = 0\): - \(A \text{ AND } B = 0 \text{ AND } 1 = 0\) - \(\text{NOT}(A \text{ AND } B) = \text{NOT}(0) = 1\) - \(B \text{ XOR } C = 1 \text{ XOR } 0 = 1\) - \(X = 1 \text{ OR } 1 = 1\)
3. For \(A = 1, B = 0, C = 1\): - \(A \text{ AND } B = 1 \text{ AND } 0 = 0\) - \(\text{NOT}(A \text{ AND } B) = \text{NOT}(0) = 1\) - \(B \text{ XOR } C = 0 \text{ XOR } 1 = 1\) - \(X = 1 \text{ OR } 1 = 1\)
Marking scheme
Award 1 mark for each correct value of \(X\): - Scenario 1: \(X = 0\) - Scenario 2: \(X = 1\) - Scenario 3: \(X = 1\)
Question 9 · Logic Gates & Algorithm Pseudocode
3 marks
Consider the following pseudocode designed to process an array of integers:
``` ARR = [12, 5, 8, 19, 3] loop I from 0 to 3 if ARR[I] > ARR[I+1] then TEMP = ARR[I] ARR[I] = ARR[I+1] ARR[I+1] = TEMP end if end loop ```
(a) Determine the final contents of the array `ARR` after this loop finishes. (b) Identify the standard sorting algorithm that uses this exact comparison and swap operation as its fundamental building block.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let us trace the loop step-by-step with the initial array `ARR = [12, 5, 8, 19, 3]`:
- **Iteration 1 (I = 0)**: Compare `ARR[0]` (12) and `ARR[1]` (5). Since \(12 > 5\), they swap. `ARR` becomes `[5, 12, 8, 19, 3]`. - **Iteration 2 (I = 1)**: Compare `ARR[1]` (12) and `ARR[2]` (8). Since \(12 > 8\), they swap. `ARR` becomes `[5, 8, 12, 19, 3]`. - **Iteration 3 (I = 2)**: Compare `ARR[2]` (12) and `ARR[3]` (19). Since \(12 > 19\) is False, no swap occurs. `ARR` remains `[5, 8, 12, 19, 3]`. - **Iteration 4 (I = 3)**: Compare `ARR[3]` (19) and `ARR[4]` (3). Since \(19 > 3\), they swap. `ARR` becomes `[5, 8, 12, 3, 19]`.
This single pass of comparing adjacent elements and swapping them if they are in the wrong order is the core pass of a **Bubble Sort** algorithm.
Marking scheme
Award 2 marks for the correct final state of the array: `[5, 8, 12, 3, 19]`. - Award 1 mark if there is exactly one incorrect element position (e.g. `[5, 12, 8, 3, 19]`). Award 1 mark for identifying the sorting algorithm as **Bubble Sort**.
Question 10 · Logic Gates & Algorithm Pseudocode
3 marks
A logic circuit is defined by the following expression: \(Z = \text{NOT}(P \text{ AND } Q) \text{ OR } Q\)
(a) Construct a truth table to determine the output \(Z\) for all combinations of inputs \(P\) and \(Q\). (b) Based on your truth table or algebraic laws, state the simplest equivalent Boolean expression for \(Z\).
Show answer & marking schemeHide answer & marking scheme
Worked solution
Let's construct the truth table:
| P | Q | P AND Q | NOT(P AND Q) | Z = NOT(P AND Q) OR Q | |---|---|---|---|---| | 0 | 0 | 0 | 1 | 1 | | 0 | 1 | 0 | 1 | 1 | | 1 | 0 | 0 | 1 | 1 | | 1 | 1 | 1 | 0 | 1 |
Alternatively, using Boolean algebra laws: \(Z = \overline{P \cdot Q} + Q\) \(Z = \overline{P} + \overline{Q} + Q\) (by De Morgan's Law) Since \(\overline{Q} + Q = 1\) (Complement Law): \(Z = \overline{P} + 1\) Since anything ORed with 1 is 1 (Annulment Law): \(Z = 1\)
Therefore, the simplest expression is \(Z = 1\) (or True).
Marking scheme
Award 1 mark for a fully correct truth table showing \(Z = 1\) for all four input combinations. Award 2 marks for simplifying the expression to \(Z = 1\) (or True) with appropriate algebraic working or correct reference to the truth table results showing a tautology. - Award 1 mark if working is shown but a minor error is made resulting in an incorrect final simplified form (e.g., \(Z = \overline{P} + Q\)).
Question 11 · practical
3.75 marks
A Collection PATIENTS contains the following array of five integer priority codes: [45, 12, 85, 32, 10]. A Selection Sort algorithm is applied to sort this Collection in ascending order. (i) State the state of the Collection after the first complete pass. (ii) State the state of the Collection after the second complete pass. (iii) State the total number of key comparisons made during these first two passes combined.
Show answer & marking schemeHide answer & marking scheme
Worked solution
During Pass 1, the algorithm scans all 5 elements to find the minimum value. It starts at index 0 and compares the current minimum with the remaining elements, making 4 comparisons. The minimum value found is 10 (at index 4), which is swapped with the value at index 0 (45). The state after Pass 1 is [10, 12, 85, 32, 45]. During Pass 2, the algorithm scans the remaining 4 elements starting at index 1 to find the minimum. It makes 3 comparisons. The minimum value is 12 (at index 1), which is already in its correct position, so it swaps with itself. The state after Pass 2 is [10, 12, 85, 32, 45]. The total comparisons made are 4 in the first pass plus 3 in the second pass, which equals 7.
Marking scheme
Award 1.25 marks for the correct state of the Collection after Pass 1: [10, 12, 85, 32, 45]. Award 1.25 marks for the correct state of the Collection after Pass 2: [10, 12, 85, 32, 45]. Award 1.25 marks for correctly calculating the total number of comparisons as 7 (with a brief explanation showing 4 comparisons in Pass 1 and 3 comparisons in Pass 2).
Question 12 · practical
3.75 marks
An algorithm uses a Bubble Sort to arrange a Collection of student grades in descending order. The initial Collection is: [65, 78, 92, 40, 85]. State the final order of elements, the total number of comparisons, and the total number of swaps executed during the very first complete pass of this Bubble Sort.
Show answer & marking schemeHide answer & marking scheme
Worked solution
To sort in descending order, adjacent elements are compared and swapped if the element on the left is smaller than the element on the right. Step 1: Compare 65 and 78. Since 65 < 78, swap them. Collection becomes [78, 65, 92, 40, 85] (1 comparison, 1 swap). Step 2: Compare 65 and 92. Since 65 < 92, swap them. Collection becomes [78, 92, 65, 40, 85] (1 comparison, 1 swap). Step 3: Compare 65 and 40. Since 65 > 40, no swap occurs. Collection remains [78, 92, 65, 40, 85] (1 comparison, 0 swaps). Step 4: Compare 40 and 85. Since 40 < 85, swap them. Collection becomes [78, 92, 65, 85, 40] (1 comparison, 1 swap). Totals for the first pass: 4 comparisons and 3 swaps.
Marking scheme
Award 1.25 marks for the correct state of the Collection at the end of the first pass: [78, 92, 65, 85, 40]. Award 1.25 marks for stating exactly 4 comparisons. Award 1.25 marks for stating exactly 3 swaps.
Question 13 · practical
3.75 marks
A system administrator is choosing between a fixed-size Array and a dynamic Collection to manage dynamic daily application logs. Contrast these two data structures by explaining how they differ in terms of memory allocation, sizing limits, and the computational overhead that occurs when adding new elements.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Arrays are static structures where memory is allocated at compile-time (or initialization) with a fixed capacity that cannot be changed. This means appending an element has a highly efficient constant time complexity of \( O(1) \), but the structure cannot exceed its pre-allocated limit. In contrast, dynamic Collections allocate memory at runtime and can dynamically resize as elements are added. However, this flexibility introduces computational overhead; when the underlying capacity of a dynamic collection is exceeded, a resizing operation occurs which requires allocating a larger block of memory and copying all existing elements over, resulting in an occasional worst-case time complexity of \( O(N) \).
Marking scheme
Award up to 1.25 marks for contrasting memory allocation (static/pre-allocated for arrays versus dynamic/run-time for collections). Award up to 1.25 marks for contrasting structural size limits (fixed bounds for arrays versus flexible/resizable limits for collections). Award up to 1.25 marks for explaining the computational overhead difference (constant time addition for arrays versus potential copy/resize overhead of \( O(N) \) for dynamic collections).
Question 14 · practical
3.75 marks
A developer suggests replacing a Sequential Search with a Binary Search to find a specific item in an unsorted Collection containing \( N \) elements. Explain why this suggestion is computationally inefficient for a single search operation, and state the conditions under which a Binary Search becomes a more appropriate choice.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Binary Search has a prerequisite that the data must be sorted. For an unsorted Collection of size \( N \), the developer would first need to sort the collection, which takes at least \( O(N \log N) \) time using an efficient algorithm like Merge Sort, and then perform the Binary Search which takes \( O(\log N) \) time. This results in a total time of \( O(N \log N) \). A single Sequential Search on the unsorted collection takes only \( O(N) \) time in the worst case, making it much faster than sorting first. Binary Search is only appropriate if the Collection is already sorted, or if the Collection is sorted once and then queried multiple times, allowing the sorting overhead to be amortized.
Marking scheme
Award 1.25 marks for identifying the prerequisite that Binary Search requires sorted data. Award 1.25 marks for explaining that sorting first adds a cost of \( O(N \log N) \) which makes the single search less efficient than a Sequential Search of \( O(N) \). Award 1.25 marks for explaining that Binary Search is only suitable when the data is pre-sorted or searched repeatedly.
Wondering how well you actually know this?
Thinka is an AI practice app for DSE students — unlimited questions, instant auto-marking, and detailed step-by-step solutions. 100,000+ students use it to confirm they actually know it, not just think they do.