An original Thinka practice paper modelled on the structure and difficulty of the Jun 2025 (V1) Cambridge International A Level Computer Science (9618) paper. Not affiliated with or reproduced from Cambridge.
Paper 11 (Theory Fundamentals)
Answer all questions. Calculators must not be used.
25 PastPaper.question · 68 PastPaper.marks
PastPaper.question 1 · Short answer logic expression
1 PastPaper.marks
A greenhouse ventilation system has three sensors: * Temperature high (\(T\)) * Humidity high (\(H\)) * Manual override (\(M\))
The ventilation fan (\(F\)) is turned on (output 1) if: * the temperature high sensor is active (\(T = 1\)) AND the manual override is NOT active (\(M = 0\)), * OR * the humidity high sensor is active (\(H = 1\)) AND the manual override is active (\(M = 1\)).
Write the Boolean expression for the output \(F\) in terms of \(T\), \(H\), and \(M\). Use the text-based operators `AND`, `OR`, and `NOT`.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To construct the logic expression from the description: 1. The first condition is 'temperature high sensor is active AND manual override is NOT active'. This translates to: \(T \text{ AND NOT } M\). 2. The second condition is 'humidity high sensor is active AND manual override is active'. This translates to: \(H \text{ AND } M\). 3. Since either condition can turn on the fan, we combine them using an `OR` operator: \((T \text{ AND NOT } M) \text{ OR } (H \text{ AND } M)\).
PastPaper.markingScheme
1 mark for correct Boolean expression: `(T AND NOT M) OR (H AND M)` or equivalent (e.g., `(T AND (NOT M)) OR (H AND M)`).
PastPaper.question 2 · Short answer logic expression
1 PastPaper.marks
A security alarm system has three binary inputs: * Motion detected (\(A\)) * Window open (\(B\)) * System armed (\(C\))
The alarm (\(Y\)) is triggered (output 1) if the system is armed (\(C = 1\)) AND at least one of the following is true: * Motion is detected (\(A = 1\)) * A window is open (\(B = 1\))
Write the Boolean expression for the output \(Y\) in terms of \(A\), \(B\), and \(C\). Use the text-based operators `AND`, `OR`, and `NOT`.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To construct the logic expression: 1. 'At least one of Motion is detected or Window is open' is written as: \(A \text{ OR } B\). 2. 'The system is armed AND at least one of those conditions is met' is written as: \(C \text{ AND } (A \text{ OR } B)\) or \((A \text{ OR } B) \text{ AND } C\).
PastPaper.markingScheme
1 mark for correct Boolean expression: `C AND (A OR B)` or equivalent commutative forms (such as `(A OR B) AND C`).
PastPaper.question 3 · Truth table filling
2 PastPaper.marks
Complete the truth table for the logic expression:
\(X = (A \text{ AND } \text{NOT } B) \text{ NOR } (A \text{ XOR } B)\)
Write the final output values for \(X\) from top to bottom as a sequence of four digits (e.g., 0, 1, 0, 1).
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To find the output \(X\) for each row of the truth table, we evaluate the expression step-by-step: Let \(P = A \text{ AND } \text{NOT } B\) Let \(Q = A \text{ XOR } B\) Then \(X = P \text{ NOR } Q = \text{NOT}(P \text{ OR } Q)\)
1. For \(A = 0, B = 0\): - \(P = 0 \text{ AND } \text{NOT } 0 = 0 \text{ AND } 1 = 0\) - \(Q = 0 \text{ XOR } 0 = 0\) - \(X = 0 \text{ NOR } 0 = 1\)
2. For \(A = 0, B = 1\): - \(P = 0 \text{ AND } \text{NOT } 1 = 0 \text{ AND } 0 = 0\) - \(Q = 0 \text{ XOR } 1 = 1\) - \(X = 0 \text{ NOR } 1 = 0\)
3. For \(A = 1, B = 0\): - \(P = 1 \text{ AND } \text{NOT } 0 = 1 \text{ AND } 1 = 1\) - \(Q = 1 \text{ XOR } 0 = 1\) - \(X = 1 \text{ NOR } 1 = 0\)
4. For \(A = 1, B = 1\): - \(P = 1 \text{ AND } \text{NOT } 1 = 1 \text{ AND } 0 = 0\) - \(Q = 1 \text{ XOR } 1 = 0\) - \(X = 0 \text{ NOR } 0 = 1\)
Thus, the sequence of outputs from top to bottom is 1, 0, 0, 1.
PastPaper.markingScheme
1 mark for two or three correct values in the column for \(X\). 2 marks for all four correct values in the column for \(X\) (1, 0, 0, 1).
PastPaper.question 4 · free-response
4 PastPaper.marks
An online streaming service delivers high-definition audio to users using bit streaming.
(a) Explain the term 'bit streaming'. [2]
(b) Describe how a buffer is used to ensure uninterrupted playback of the audio when the network transmission speed fluctuates. [2]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
(a) Bit streaming is a method of transmitting data over a network in a continuous flow (a sequence of bits). This allows the data (audio or video) to be processed, decoded, and played back by the receiver's media player in real-time as it arrives, without needing the entire file to be downloaded beforehand.
(b) A buffer is a dedicated, temporary storage area in the client computer's memory. As the stream is downloaded, data is stored in the buffer before playback begins. If the network speed drops momentarily, the media player continues to play the data currently stored in the buffer. This prevents playback stuttering (jitter) or pausing, allowing time for the network speed to recover and refill the buffer.
PastPaper.markingScheme
Part (a): Max 2 marks - 1 mark: Definition of bit streaming as a continuous flow of digital data / sequence of bits transmitted over a network. - 1 mark: Explanation that data is decoded/played back in real-time / as it arrives, without waiting for the full file to download.
Part (b): Max 2 marks - 1 mark: Explaining that a buffer acts as a temporary storage area in memory holding a portion of the incoming stream. - 1 mark: Explaining that if network speed drops, the player reads from the buffer, absorbing the delay to prevent interruption/stuttering.
PastPaper.question 5 · free-response
4 PastPaper.marks
A live security camera stream uses video compression before transmitting data over a wireless connection.
(a) Explain why lossy compression is appropriate for this video stream, whereas lossless compression must be used for software executable files. [2]
(b) Identify and describe one lossy compression technique that can be applied to reduce the size of the video stream. [2]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
(a) Lossy compression permanently discards redundant or less perceptible data (such as subtle color variations), resulting in a significantly smaller file size and lower bandwidth requirement, which is critical for real-time video streaming where minor quality loss is acceptable. In contrast, software executables require lossless compression because every single bit is essential to the instructions; any data loss would corrupt the file, making it unusable and preventing the program from running.
(b) Temporal compression (or inter-frame compression): This technique analyzes consecutive video frames and only transmits the pixels that change from one frame to the next (differences), rather than transmitting full, independent images for every single frame.
PastPaper.markingScheme
Part (a): Max 2 marks - 1 mark: Lossy compression removes unnecessary/unnoticeable detail, which drastically reduces bandwidth/file size, making it suitable for streaming where absolute precision is not critical. - 1 mark: Lossless compression preserves every bit of data, which is essential for executable files because any missing or altered instructions will cause program execution to fail/corrupt.
Part (b): Max 2 marks - 1 mark: Identification of a valid lossy video compression technique (e.g., Temporal compression / inter-frame compression, Spatial compression / intra-frame compression, or Chroma subsampling). - 1 mark: Accurate description of the identified technique (e.g., Temporal: only sending differences between frames; Spatial: applying lossy JPEG-like compression to individual frames; Chroma subsampling: reducing color resolution while preserving brightness data).
PastPaper.question 6 · free-response
4 PastPaper.marks
An audio stream is recorded with a sample rate of 44,100 Hz, a bit depth of 16 bits, and uses 2 channels (stereo).
(a) Calculate the bit rate of this audio stream in kilobits per second (kbps). Show your working. [2]
(b) The audio stream needs to be transmitted over a network with a bandwidth of 1 Mbps. State, with a reason, whether this network can reliably support the real-time transmission of this audio stream. [2]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
(a) Working: \( \text{Bit rate} = \text{Sample Rate} \times \text{Bit Depth} \times \text{Number of Channels} \) \( \text{Bit rate} = 44,100 \times 16 \times 2 = 1,411,200 \text{ bits per second (bps)} \) Converting to kbps using metric standards (divided by 1000): \( 1,411,200 / 1000 = 1411.2 \text{ kbps} \) (Or, if converting using binary base-2 standards: \( 1,411,200 / 1024 \approx 1378.1 \text{ kbps} \))
(b) No, the network cannot reliably support real-time transmission. The calculated bit rate is approximately 1.4 Mbps (1411.2 kbps). Because the network bandwidth is only 1 Mbps, the delivery rate of the stream is slower than the playback rate, leading to constant buffer underruns and playback stuttering.
PastPaper.markingScheme
Part (a): Max 2 marks - 1 mark: Correct working showing multiplication of all factors: \( 44,100 \times 16 \times 2 \). - 1 mark: Correct final calculation with units (1411.2 kbps or 1378.1 kbps / 1378 kbps).
Part (b): Max 2 marks - 1 mark: Correct statement (No / cannot support). - 1 mark: Clear explanation comparing the stream's requirements (~1.4 Mbps) with the network's throughput capacity (1 Mbps), concluding that the stream rate exceeds the network bandwidth.
PastPaper.question 7 · practical
2 PastPaper.marks
A graphic designer creates a simple custom icon with a resolution of 64 by 64 pixels. The icon uses a color palette of exactly 32 distinct colors. Calculate the minimum file size of the image data (excluding any metadata) in bytes. Show your working.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. Determine the color depth (number of bits per pixel): A palette of 32 colors requires \(\log_2(32) = 5\) bits per pixel. 2. Calculate the total number of pixels: \(64 \times 64 = 4096\) pixels. 3. Calculate the total file size in bits: \(4096 \text{ pixels} \times 5 \text{ bits} = 20480\) bits. 4. Convert bits to bytes: \(20480 / 8 = 2560\) bytes.
PastPaper.markingScheme
1 mark for calculating the correct color depth of 5 bits (or total bits as 20480 bits). 1 mark for the correct final answer of 2560 bytes with correct units.
PastPaper.question 8 · theory
2 PastPaper.marks
Besides pixel data, a bitmap image file includes a file header containing metadata. State two items of metadata stored in a bitmap file header, other than the image dimensions (width and height).
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
A bitmap file header contains metadata that allows the computer system to correctly interpret and display the raw pixel data. Common metadata elements excluding width and height include: - Color depth / Bit depth (specifying how many bits represent each pixel) - Image resolution (e.g., dots per inch) - Compression type / method used - File size - Date and time of creation / author metadata.
PastPaper.markingScheme
1 mark for each valid metadata item listed (up to a maximum of 2 marks). Acceptable: Color depth / bit depth, Image resolution (dpi/ppi), Compression type, File size, Date/time of creation.
PastPaper.question 9 · theory
2 PastPaper.marks
An artist needs to design a company logo that will be printed on small business cards as well as scaled up to fit giant roadside billboards. Explain why a vector graphic is more suitable than a bitmap graphic for this design, referencing two specific characteristics of vector graphics.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. Scalability: Vector graphics are defined by mathematical formulas and geometric shapes rather than a fixed grid of pixels. This allows the logo to be resized (scaled up or down) to any dimensions without losing sharpness or becoming pixelated (retaining sharp edges on a billboard). 2. File size: The file size of a vector graphic depends on the complexity of the shapes/objects drawn, not the physical dimensions of the output image. Therefore, a massive billboard version of the logo will not result in a giant file size.
PastPaper.markingScheme
1 mark for explaining that vector graphics are made of mathematical shapes/formulas allowing scaling/resizing without pixelation or loss of quality. 1 mark for explaining that file size remains small because it is determined by the number of objects/complexity rather than physical dimensions.
PastPaper.question 10 · practical
2 PastPaper.marks
A single row of a simple 8-color bitmap image is represented by the following sequence of pixel color values: W, W, W, B, B, B, B, G, G, W (where W = White, B = Black, G = Green). Show how this row would be compressed using Run-Length Encoding (RLE), and state the final compressed sequence.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Run-Length Encoding (RLE) is a lossless compression technique that replaces consecutive repeating values (runs) with a single value and a count of how many times it repeats. - 'W, W, W' is 3 consecutive White pixels: 3W. - 'B, B, B, B' is 4 consecutive Black pixels: 4B. - 'G, G' is 2 consecutive Green pixels: 2G. - 'W' is 1 White pixel: 1W. Combining these gives the compressed sequence: 3W, 4B, 2G, 1W (or equivalent notation like (3, W), (4, B), (2, G), (1, W)).
PastPaper.markingScheme
1 mark for identifying the correct runs and counts (e.g., 3 Ws, 4 Bs, 2 Gs, 1 W). 1 mark for presenting the final compressed sequence in a clear, consistent notation (e.g., 3W, 4B, 2G, 1W or (3,W), (4,B), (2,G), (1,W)).
PastPaper.question 11 · short_answer
2 PastPaper.marks
An Entity-Relationship (ER) diagram shows a relationship between a CUSTOMER entity and an ORDER entity. One customer can place many orders, but each order belongs to only one customer. Identify the primary key of the CUSTOMER table and explain how the relationship is established in the ORDER table.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The CUSTOMER table requires a unique identifier, such as CustomerID, to act as its primary key. To represent the one-to-many relationship in the relational database, this CustomerID is added to the ORDER table as a foreign key.
PastPaper.markingScheme
1 mark for identifying a suitable primary key (e.g. CustomerID / Customer Number). 1 mark for stating that this primary key is placed in the ORDER table as a foreign key.
PastPaper.question 12 · short_answer
2 PastPaper.marks
A relational database contains a table named STUDENT_SPONSOR to resolve a many-to-many relationship between STUDENT and SPONSOR. State the technical term used for this type of linking table, and explain how the primary key for STUDENT_SPONSOR would normally be constructed.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The STUDENT_SPONSOR table is a junction/link table. Its primary key is constructed by combining the primary keys of the two related tables (StudentID and SponsorID) to form a composite primary key.
PastPaper.markingScheme
1 mark for the term: junction table / link table / associative entity. 1 mark for explaining that it uses a composite primary key formed by combining the primary keys from STUDENT and SPONSOR tables.
PastPaper.question 13 · short_answer
2 PastPaper.marks
Consider the following database design for a flight booking system: FLIGHT(FlightNumber, DepartureAirport, ArrivalAirport) and PASSENGER_BOOKING(BookingID, FlightNumber, PassengerID, SeatNumber). Assuming FlightNumber is unique, identify the candidate key for the FLIGHT table, and state the role of FlightNumber in the PASSENGER_BOOKING table.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
In the FLIGHT table, FlightNumber is the unique identifier and therefore acts as the candidate key (which will be chosen as the primary key). In the PASSENGER_BOOKING table, FlightNumber serves to link the booking to the flight, which makes it a foreign key.
PastPaper.markingScheme
1 mark for identifying FlightNumber as the candidate key. 1 mark for identifying FlightNumber in PASSENGER_BOOKING as a foreign key.
PastPaper.question 14 · practical
4 PastPaper.marks
A travel company uses a relational database to store information about customers and their bookings. The database has two tables with the following schemas: [1] tblCustomer (CustomerID, FirstName, LastName, Email) [2] tblBooking (BookingID, CustomerID, BookingDate, AmountPaid). Write an SQL query to display the FirstName and LastName of the customers, and the AmountPaid for all bookings that occurred on or after the date '2023-11-01'. The output must be sorted in descending order of the AmountPaid.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To retrieve and display the correct records, we must join the two tables using their common field, CustomerID. The SELECT clause specifies the fields to display: FirstName, LastName, and AmountPaid. The FROM clause joins tblCustomer and tblBooking on CustomerID. The WHERE clause filters for records where BookingDate is greater than or equal to '2023-11-01'. Finally, the ORDER BY clause sorts the results by AmountPaid in descending order (DESC).
PastPaper.markingScheme
Award 1 mark for each of the following points, up to a maximum of 4 marks: [1] Correct SELECT clause listing FirstName, LastName, and AmountPaid (table prefixes are optional but recommended). [2] Correct join syntax linking tblCustomer and tblBooking on CustomerID (either INNER JOIN ... ON tblCustomer.CustomerID = tblBooking.CustomerID or implicit WHERE tblCustomer.CustomerID = tblBooking.CustomerID join). [3] Correct WHERE condition filtering for BookingDate >= '2023-11-01'. [4] Correct ORDER BY clause sorting by AmountPaid DESC.
PastPaper.question 15 · short_answer
3 PastPaper.marks
An industrial control panel uses a resistive touch screen. Describe how a touch is detected and its location is determined by this type of screen.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
A resistive touch screen operates using two conductive and resistive layers separated by an air gap or microscopic spacer dots. 1. When a finger or stylus presses the flexible outer layer, it bends and makes physical contact with the inner layer. 2. This contact completes an electrical circuit at the point of touch, causing a change in the electrical current/resistance. 3. Sensors at the edges of the screen detect this change, and an internal microprocessor calculates the horizontal and vertical coordinates of the touch based on the change in voltage.
PastPaper.markingScheme
Award 1 mark per point up to a maximum of 3: - Describe the layers: Screen has two conductive/resistive layers separated by an air gap / spacer dots. - Describe physical action: Pressing the screen bends the outer layer to touch the inner layer, completing an electrical circuit. - Describe electrical / processing action: The contact changes the resistance/voltage at that point, which a processor uses to calculate the \(X\) and \(Y\) coordinates.
PastPaper.question 16 · short_answer
3 PastPaper.marks
Explain how data is read from a DVD-ROM optical disc by a computer's optical drive.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To read data from a DVD-ROM: 1. A red laser diode shines a beam of light onto the reflective surface of the disc while it is spinning. 2. The laser follows a spiral track containing flat areas called 'lands' and microscopic depressions called 'pits'. 3. Lands reflect the laser light directly back to an optoelectronic sensor (photodiode), whereas pits scatter the laser light, resulting in less reflection. The changes in light intensity of the reflected laser beam are converted into electrical pulses (binary 1s and 0s) by the drive's controller.
PastPaper.markingScheme
Award 1 mark per point up to a maximum of 3: - Mentions that a laser beam is shone onto the spinning disc's surface. - Explains that the laser tracks a spiral path containing lands and pits. - Explains that lands reflect light and pits scatter/absorb light (or that the intensity of reflected light changes). - Mentions that a sensor (photodiode) detects the reflected light and converts the transitions/intensity changes into digital/binary signals (1s and 0s).
PastPaper.question 17 · short_answer
3 PastPaper.marks
A design studio uses a 3D printer to create plastic prototypes. Describe the steps involved when a 3D printer produces a physical object from a digital model.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
First, the digital CAD (Computer-Aided Design) model must be processed by slicing software, which translates the 3D model into thousands of thin, horizontal 2D layers. Second, the 3D printer uses an extruder nozzle that is heated to melt a solid plastic filament (such as PLA or ABS). The nozzle deposits the molten material onto a build platform, moving along the \(X\) and \(Y\) axes. Third, the printer builds the object layer-by-layer (additive manufacturing), moving the nozzle or build platform along the \(Z\) axis after each layer is laid down and cooled/cured, until the complete physical prototype is formed.
PastPaper.markingScheme
Award 1 mark per point up to a maximum of 3: - Mentions slicing: The 3D digital/CAD model is sliced into thin horizontal 2D layers. - Mentions material extrusion: Plastic filament is heated/melted and extruded/deposited through a nozzle onto a build plate. - Mentions additive process: The object is built layer-by-layer (by movement along the \(Z\) axis as well as \(X\) and \(Y\) axes) until the object is complete.
PastPaper.question 18 · descriptive
5 PastPaper.marks
An operating system (OS) is responsible for managing memory and processes (processor time) in a multitasking computer system.
Describe how the operating system performs **memory management** and **process management** when multiple applications are running concurrently.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To manage memory, the OS acts as a gatekeeper for RAM. It allocates blocks of memory to processes when they start, tracks which portions of memory are in use, ensures processes do not interfere with each other's memory blocks (protection), and frees up memory when processes terminate. If RAM is full, the OS implements virtual memory using paging or segmentation.
To manage processes, the OS uses a scheduler to allocate processor time slices to individual processes, ensuring fair execution and multitasking. It manages process priorities and transitions processes through states (Ready, Running, Blocked). It also handles interrupts and performs context switching, which involves saving the current CPU register values for one process and loading those of another.
PastPaper.markingScheme
Award 1 mark per valid point up to a maximum of 5 marks. (Allow a maximum of 3 marks for memory management and a maximum of 3 marks for process management)
Memory management points (Max 3): - Keeps track of memory allocation (which parts of RAM are free or in use) [1] - Allocates RAM space to processes when they load [1] - Prevents processes from accessing/overwriting memory allocated to another process (protection/isolation) [1] - Deallocates RAM when a process terminates [1] - Implements/manages virtual memory / paging / segmentation when physical RAM is full [1]
Process management points (Max 3): - Uses a scheduler / scheduling algorithm (e.g., Round Robin, priority) to allocate CPU time [1] - Manages and adjusts process priorities [1] - Manages process states (e.g., Ready, Running, Blocked) [1] - Handles interrupts [1] - Performs context switching (saving registers/state of a process and loading another) to allow multitasking [1]
PastPaper.question 19 · short-answer
4 PastPaper.marks
An email sender, Alice, wants to send a sensitive document to Bob. She decides to use a digital signature to ensure authenticity and integrity. Explain how the digital signature is created by Alice and verified by Bob.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To create the digital signature, Alice runs the document through a cryptographic hash function to produce a unique message digest. She then encrypts this message digest using her private key. The resulting ciphertext is the digital signature, which is sent along with the original document. To verify the signature, Bob decrypts the digital signature using Alice's public key, which reveals the original message digest. Bob then runs the received document through the same cryptographic hash function to produce a new digest. If Bob's newly calculated digest matches the decrypted digest, Bob is assured that the document has not been altered (integrity) and that it indeed originated from Alice (authenticity).
PastPaper.markingScheme
1 mark: Alice applies a cryptographic hash function to the document to create a unique message digest. 1 mark: Alice encrypts this message digest using her private key to create the digital signature. 1 mark: Bob decrypts the received digital signature using Alice's public key to recover the message digest. 1 mark: Bob hashes the received document and compares this new digest to the decrypted digest to verify authenticity and integrity.
PastPaper.question 20 · short-answer
4 PastPaper.marks
When sending a large backup file over the internet, a system administrator decides to use a hybrid encryption system combining asymmetric and symmetric encryption. Explain how these two encryption methods are combined to securely transmit the file, and state why this combined approach is preferred over using asymmetric encryption alone.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The hybrid process works as follows: First, a symmetric key is generated by the sender and used to encrypt the large backup file. Second, the symmetric key itself is encrypted using the recipient's public key (asymmetric encryption). Both the encrypted file and the encrypted symmetric key are then transmitted over the network. Third, upon receipt, the recipient uses their private key to decrypt the symmetric key. Finally, the recipient uses the decrypted symmetric key to decrypt the backup file. This approach is preferred because symmetric encryption is highly efficient and much faster than asymmetric encryption when processing large files. By using asymmetric encryption only to encrypt and transmit the small symmetric key, the system gains the speed of symmetric encryption alongside the secure key distribution benefits of asymmetric encryption.
PastPaper.markingScheme
1 mark: A symmetric key is generated and used to encrypt the large backup file. 1 mark: The symmetric key is encrypted using the recipient's asymmetric public key. 1 mark: The recipient uses their asymmetric private key to decrypt the symmetric key. 1 mark: Explains that symmetric encryption is computationally faster for large files, while asymmetric encryption is used to solve the key distribution problem safely.
PastPaper.question 21 · short-answer
4 PastPaper.marks
An e-commerce website uses a digital certificate to establish secure HTTPS connections with clients. Describe the role of a Certificate Authority (CA) in issuing a digital certificate, and explain how a web browser uses this certificate to verify the identity of the website.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Role of CA: The website owner submits their identification details and their public key to a trusted Certificate Authority (CA). The CA performs identity verification checks to ensure the applicant owns the domain name. Once verified, the CA generates a digital certificate containing the website's public key and identity information, and signs this certificate using the CA's own private key. Browser Verification: When a browser connects to the website, the server sends its digital certificate. The browser decrypts the digital signature on the certificate using the pre-installed public key of the CA. If decryption is successful, it confirms the certificate was signed by the trusted CA. The browser then checks that the certificate is still within its validity period, has not been revoked, and matches the domain name of the website being visited.
PastPaper.markingScheme
1 mark: The CA verifies the identity of the website owner/applicant. 1 mark: The CA generates the certificate containing the applicant's public key and signs it using the CA's private key. 1 mark: The web browser decrypts the digital signature on the certificate using the pre-installed public key of the CA to verify its authenticity. 1 mark: The browser verifies validity constraints such as the certificate has not expired, is not revoked, and matches the website domain.
PastPaper.question 22 · short_answer
2 PastPaper.marks
The accumulator initially contains the 8-bit binary value 1100 1010. The following assembly language instructions are run: LSR 3 followed by XOR &0F. State the final 8-bit binary value in the accumulator.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. LSR 3: Shift the accumulator contents 1100 1010 right by 3 places, filling with zeros from the left. This results in 0001 1001. 2. XOR &0F: Perform a bitwise XOR with &0F (0000 1111). 0001 1001 XOR 0000 1111 = 0001 0110.
PastPaper.markingScheme
1 mark for performing the correct LSR 3 shift to get 0001 1001 (or equivalent representation). 1 mark for the correct final binary value 0001 0110 after the XOR operation.
PastPaper.question 23 · short_answer
2 PastPaper.marks
The accumulator initially contains the 8-bit binary value 0011 0101. The following assembly language instructions are run: LSL 2 followed by AND &F0. State the final 8-bit binary value in the accumulator.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. LSL 2: Shift the accumulator contents 0011 0101 left by 2 places, filling with zeros from the right. This results in 1101 0100. 2. AND &F0: Perform a bitwise AND with &F0 (1111 0000). 1101 0100 AND 1111 0000 = 1101 0000.
PastPaper.markingScheme
1 mark for performing the correct LSL 2 shift to get 1101 0100. 1 mark for the correct final binary value 1101 0000 after the AND operation.
PastPaper.question 24 · short_answer
2 PastPaper.marks
An 8-bit register contains the unsigned binary representation of the denary number 75. A logical shift left of two places (LSL 2) is performed on the register. (a) State the resulting 8-bit binary value after the shift. (b) Explain why the resulting binary value does not represent the mathematically correct value of 75 multiplied by 4.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
75 in binary is 0100 1011. Shifting this left by 2 bits results in 0010 1100. Mathematically, 75 * 4 = 300. Since 300 is greater than the maximum value an 8-bit unsigned register can represent (255), overflow occurs and the most significant bit (the 1 at bit position 6) is lost.
PastPaper.markingScheme
1 mark for the correct binary value 0010 1100. 1 mark for explaining that overflow occurred because the result (300) exceeds the maximum representable value (255) / the most significant 1 bit was shifted out of the register.
PastPaper.question 25 · short_answer
2 PastPaper.marks
An assembly language program contains the following instructions: LDD 200, LSR 2, ADD 201, STO 202. The memory contents are: Address 200 contains 0110 1000, Address 201 contains 0000 0111, Address 202 contains 0000 0000. Trace the execution and state the final 8-bit binary value stored in address 202.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. LDD 200: Accumulator loaded with 0110 1000. 2. LSR 2: Accumulator shifted right by 2 bits, yielding 0001 1010 (denary 26). 3. ADD 201: Add the value at address 201 (0000 0111, denary 7) to the accumulator. 0001 1010 + 0000 0111 = 0010 0001 (denary 33). 4. STO 202: Store accumulator value 0010 0001 into address 202.
PastPaper.markingScheme
1 mark for showing the correct accumulator value after the LSR 2 operation (0001 1010). 1 mark for the correct final binary value in address 202 (0010 0001).
Paper 21 (Problem-solving and Programming Skills)
Answer all questions. Refer to the insert for functions.
17 PastPaper.question · 73 PastPaper.marks
PastPaper.question 1 · open-ended
4 PastPaper.marks
A programmer is designing an algorithm to find and output the name of the student with the highest score from a class of 30 students. The names and scores are stored in two separate parallel 1D arrays.
Complete the identifier table below by writing the appropriate Identifier, Data Type, or Description for the missing entries A, B, C, and D.
| Identifier | Data Type | Description | | :--- | :--- | :--- | | StudentNames | **A** | Array storing the names of the 30 students | | StudentScores | ARRAY[1:30] OF INTEGER | Array storing the test scores of the 30 students | | **B** | INTEGER | Stores the highest test score found during the search | | HighestName | **C** | Stores the name of the student who achieved the highest score | | Index | INTEGER | **D** |
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To complete the identifier table: 1. **A**: The identifier StudentNames represents an array that stores names. In pseudocode, this is declared as an array of string containing 30 elements: ARRAY[1:30] OF STRING. 2. **B**: The variable is used to store the highest test score found. A meaningful identifier matching standard camelCase or PascalCase convention is HighestScore or MaxScore. 3. **C**: The identifier HighestName stores a name, so its data type must be STRING. 4. **D**: The variable Index is an integer used as the loop control variable or loop counter to iterate through the array elements.
PastPaper.markingScheme
1 mark for each correct answer: - A: ARRAY[1:30] OF STRING (Accept: ARRAY OF STRING) - B: HighestScore (Accept: MaxScore / Highest / Max) - C: STRING - D: Loop counter / loop index / array index / loop control variable
An algorithm is being designed to validate data entered into an online system.
Complete the following table by placing one tick (\(\checkmark\)) in each row to identify the most appropriate validation check for each requirement.
| Requirement | Type check | Range check | Format check | Length check | Presence check | | :--- | :---: | :---: | :---: | :---: | :---: | | A student's exam score must be a whole number. | | | | | | | An employee's monthly salary must be between $1,000 and $10,000 inclusive. | | | | | | | A vehicle registration plate must have the structure of two letters, two digits, and three letters. | | | | | | | An international telephone number must not exceed 15 digits. | | | | | | | The billing address field in an e-commerce checkout form must not be left blank. | | | | | |
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The completed table with correct classifications is shown below:
| Requirement | Type check | Range check | Format check | Length check | Presence check | | :--- | :---: | :---: | :---: | :---: | :---: | | A student's exam score must be a whole number. | \(\checkmark\) | | | | | | An employee's monthly salary must be between $1,000 and $10,000 inclusive. | | \(\checkmark\) | | | | | A vehicle registration plate must have the structure of two letters, two digits, and three letters. | | | \(\checkmark\) | | | | An international telephone number must not exceed 15 digits. | | | | \(\checkmark\) | | | The billing address field in an e-commerce checkout form must not be left blank. | | | | | \(\checkmark\) |
### Explanation: - **Type check**: Ensures that the input value is of the correct data type (e.g. integer vs string). - **Range check**: Ensures that a numeric input value lies within a specific range of values. - **Format check**: Ensures that the input characters conform to a predefined pattern/template. - **Length check**: Ensures that the input string does not exceed (or is not less than) a certain number of characters. - **Presence check**: Ensures that a required field is not left empty by the user.
PastPaper.markingScheme
Award 1 mark for each correctly identified row: - Row 1: Tick in 'Type check' column only (1 mark) - Row 2: Tick in 'Range check' column only (1 mark) - Row 3: Tick in 'Format check' column only (1 mark) - Row 4: Tick in 'Length check' column only (1 mark) - Row 5: Tick in 'Presence check' column only (1 mark)
Note: If a row has more than one tick, award 0 marks for that row.
PastPaper.question 3 · Decomposition description
3 PastPaper.marks
A programmer is designing a software application to manage student grade reports. The application needs to allow a teacher to input student marks, calculate the average grade for the class, and generate a printed report showing students who scored below a specific threshold. Identify three distinct sub-tasks that this application can be decomposed into.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Decomposition is the process of breaking down a complex problem into smaller, more manageable sub-problems. In this scenario, the application can be decomposed into three logical, distinct components: 1. Input/Validation sub-task: To handle the entry of student names and marks. 2. Processing sub-task: To calculate the average grade of the class by summing the marks and dividing by the count. 3. Reporting sub-task: To compare each grade against the threshold and output the report of students below that threshold.
PastPaper.markingScheme
Award 1 mark for each valid, distinct sub-task identified, up to a maximum of 3 marks. Correct sub-tasks include: Inputting student names/marks; Validating input grades; Calculating the class average; Checking marks against the threshold; Generating/printing the final report. Do not credit general programming tasks that are not specific to this scenario (e.g., 'creating variables' or 'starting the compiler').
PastPaper.question 4 · Open-ended
1 PastPaper.marks
A programmer designs a flowchart to calculate the average of all positive elements in an integer array MyArray of size 10 (indexed 1 to 10). The flowchart steps are: Step 1: Set Sum = 0, Count = 0, Index = 1. Step 2: If Index > 10 is True, go to Step 6, else go to Step 3. Step 3: If MyArray[Index] > 0 is True, go to Step 4, else go to Step 5. Step 4: Set Sum = Sum + MyArray[Index] and Count = Count + 1. Go back to Step 2. Step 5: Set Index = Index + 1. Go back to Step 2. Step 6: If Count > 0 is True, set Average = Sum / Count and output Average, else output 'Error'. End. State the correction required to resolve the logic loop error.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
In the current flowchart, if MyArray[Index] is positive, the algorithm executes Step 4. Step 4 updates Sum and Count but does not increment the loop variable Index. It then loops back to Step 2, creating an infinite loop on the same index. To resolve this, Step 4 must either increment Index (Index = Index + 1) or transition to Step 5 before returning to Step 2.
PastPaper.markingScheme
1 mark for stating that Index must be incremented in Step 4, or that Step 4 must transition to Step 5.
PastPaper.question 5 · Open-ended
1 PastPaper.marks
An algorithm is designed to find the minimum value in an array Numbers containing 10 positive integers. The flowchart steps are: Step 1: Set Min = 0, Index = 1. Step 2: If Index > 10 is True, output Min and End, else go to Step 3. Step 3: If Numbers[Index] < Min is True, set Min = Numbers[Index]. Step 4: Set Index = Index + 1. Go to Step 2. Identify the logic error and state how to correct it.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Initializing Min to 0 is a logic error because all numbers in the array are positive (greater than 0). The condition Numbers[Index] < Min will never be true, resulting in the algorithm outputting 0. To fix this, Min should be initialized to Numbers[1] (or the first element).
PastPaper.markingScheme
1 mark for identifying that Min is incorrectly initialized to 0 and proposing initialization to the first element (Numbers[1]) or a sufficiently large value.
PastPaper.question 6 · short answer
2 PastPaper.marks
A programmer writes a recursive function to compute factorials, but omits the base case. When the program runs, it crashes with a "stack overflow" message.
State the category of error this represents and explain why it is classified as this type of error.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The error is classified as a runtime error (or run-time error).
This is because the code is syntactically correct and will successfully compile or pass initial translation checks. However, during execution, the infinite recursion causes the call stack to run out of memory, leading to an abnormal termination (crash) of the program.
PastPaper.markingScheme
1 mark: Identify as a "runtime error" (or "run-time error"). 1 mark: Explain that the program compiles/translates successfully but crashes/abnormally terminates during execution (due to stack overflow/memory exhaustion).
PastPaper.question 7 · short answer
2 PastPaper.marks
In software development, identifiers can be declared as constants rather than variables.
State two benefits of using constants instead of variables for values that do not change during program execution.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Using constants provides the following key advantages: 1. **Prevention of Accidental Changes**: The compiler/interpreter ensures that any attempt to reassign or modify the constant's value during execution results in an error, protecting data integrity. 2. **Readability and Maintainability**: It is easier to understand what a named constant (e.g., `MAX_USERS`) represents compared to a literal number (e.g., `100`). Furthermore, if the value needs to change in the future, it only needs to be updated in a single place at declaration.
PastPaper.markingScheme
1 mark per valid benefit (maximum 2): - Prevents accidental changes/writes to the value during program execution. - Improves readability/understanding of the code (by using meaningful names instead of hardcoded literals). - Simplifies code maintenance/updating (the value only needs to be altered once in the definition). - Facilitates compiler optimizations.
PastPaper.question 8 · short answer
2 PastPaper.marks
A student attempts to calculate the average of three scores using the assignment statement:
Identify the specific category of error present in this statement and explain how the program behaves when this line is executed.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The category of error is a logic error.
The program will execute to completion without crashing or generating any error messages. However, due to operator precedence, only `Score3` is divided by 3, and the result is added to `Score1` and `Score2`, producing an incorrect mathematical result.
PastPaper.markingScheme
1 mark: Identify the error as a "logic error" (or "logical error"). 1 mark: Explain that the program runs to completion/does not crash but yields an incorrect or unexpected output (due to operator precedence dividing only the third score).
PastPaper.question 9 · short answer
2 PastPaper.marks
State which error classification (syntax, runtime, or logic) is typically detected before execution begins by a compiler, and describe how this detection differs when using a standard interpreter.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The error classification detected before execution by a compiler is a syntax error.
A compiler analyzes the entire source code file during the translation phase and reports syntax errors before any executable code is produced. In contrast, an interpreter translates and executes source code line-by-line (or statement-by-statement), meaning it will only detect and report a syntax error when execution reaches the specific line containing that error.
PastPaper.markingScheme
1 mark: Identify "syntax error". 1 mark: Describe the difference: Compiler checks the entire program and flags syntax errors before execution / interpreter translates line-by-line and only flags the syntax error when that line is reached during execution.
PastPaper.question 10 · practical
8 PastPaper.marks
A software program processes retail transactions. A user-defined composite data type, SaleRecord, is defined as follows:
TYPE SaleRecord DECLARE ProductID : STRING DECLARE Category : STRING DECLARE Amount : REAL ENDTYPE
A global array, SalesData, is declared as: DECLARE SalesData : ARRAY[1:100] OF SaleRecord
Write pseudocode for a procedure, CalculateCategoryStats, which takes a single string parameter, TargetCategory. The procedure must: 1. Loop through all 100 elements of the SalesData array. 2. Identify records where the Category matches the TargetCategory (case-sensitive) and the Amount is greater than 0.0 (amounts of 0.0 or less represent returned items and must be ignored). 3. Calculate the total sales amount and the count of valid transactions for the matched category. 4. If there is at least one valid transaction, calculate the average sales amount for that category, and output the total, the count, and the average with appropriate labels. 5. If no valid transactions are found for the category, output an appropriate error message (e.g., 'No sales found for category') instead of calculating the average.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The solution utilizes standard Cambridge pseudocode structures.
PROCEDURE CalculateCategoryStats(TargetCategory : STRING) DECLARE Total : REAL DECLARE Count : INTEGER DECLARE Average : REAL DECLARE Index : INTEGER
Total <- 0.0 Count <- 0
FOR Index <- 1 TO 100 IF SalesData[Index].Category = TargetCategory THEN IF SalesData[Index].Amount > 0.0 THEN Total <- Total + SalesData[Index].Amount Count <- Count + 1 ENDIF ENDIF ENDFOR
IF Count > 0 THEN Average <- Total / Count OUTPUT "Total Sales: ", Total OUTPUT "Number of Sales: ", Count OUTPUT "Average Sale: ", Average ELSE OUTPUT "No sales found for category" ENDIF ENDPROCEDURE
PastPaper.markingScheme
Award marks as follows (Max 8 marks): 1. Correct procedure header (including parameter name and type) and corresponding ENDPROCEDURE. 2. Correct declaration and initialization of Total (to 0.0) and Count (to 0). 3. Correct FOR loop from 1 to 100 to process the entire array. 4. Correct conditional statement to check if the record category matches TargetCategory (e.g., SalesData[Index].Category = TargetCategory). 5. Correct check that the amount is greater than 0.0 (e.g., SalesData[Index].Amount > 0.0). 6. Correct accumulation of running total and incrementation of count inside the selection blocks. 7. Correct check after loop execution to verify Count > 0 before calculating average (preventing division-by-zero errors). 8. Correct calculation of average, output of total, count, and average with labels, and an appropriate alternative output message when no matches are found.
PastPaper.question 11 · Dry run table completion
6 PastPaper.marks
An algorithm is represented by the following pseudocode:
```pseudocode FUNCTION Analyse(Values : ARRAY OF INTEGER, Size : INTEGER) RETURNS INTEGER DECLARE i : INTEGER DECLARE Score : INTEGER
Score <- 0 FOR i <- 1 TO Size - 1 IF Values[i] < Values[i + 1] THEN Score <- Score + (Values[i + 1] - Values[i]) ELSE Score <- Score - 1 ENDIF NEXT i RETURN Score ENDFUNCTION ```
An array `MyArray` contains the following 6 elements:
To trace the function `Analyse(MyArray, 6)`: 1. **Initialization**: - `Score` is initialized to `0` before the loop begins.
2. **Iteration i = 1**: - `Values[1]` is `8` and `Values[2]` is `12`. - The condition `8 < 12` evaluates to `TRUE`. - `Score <- Score + (12 - 8) = 0 + 4 = 4`.
3. **Iteration i = 2**: - `Values[2]` is `12` and `Values[3]` is `12`. - The condition `12 < 12` evaluates to `FALSE`. - `Score <- Score - 1 = 4 - 1 = 3`.
4. **Iteration i = 3**: - `Values[3]` is `12` and `Values[4]` is `9`. - The condition `12 < 9` evaluates to `FALSE`. - `Score <- Score - 1 = 3 - 1 = 2`.
5. **Iteration i = 4**: - `Values[4]` is `9` and `Values[5]` is `15`. - The condition `9 < 15` evaluates to `TRUE`. - `Score <- Score + (15 - 9) = 2 + 6 = 8`.
6. **Iteration i = 5**: - `Values[5]` is `15` and `Values[6]` is `10`. - The condition `15 < 10` evaluates to `FALSE`. - `Score <- Score - 1 = 8 - 1 = 7`.
PastPaper.markingScheme
1 mark per bullet point (Max 6 marks): - Correctly enters initial `Score` value of `0` in the first row. - Correctly fills column `i` with sequence `1`, `2`, `3`, `4`, `5`. - Correctly completes the array access columns `Values[i]` and `Values[i+1]` for all iterations. - Correctly evaluates the condition column `Values[i] < Values[i+1]` as `TRUE`, `FALSE`, `FALSE`, `TRUE`, `FALSE`. - Correctly calculates the value of `Score` for iterations `i = 1`, `i = 2`, and `i = 3` (values: `4`, `3`, `2`). - Correctly calculates the value of `Score` for iterations `i = 4` and `i = 5` (values: `8`, `7`).
PastPaper.question 12 · practical
7 PastPaper.marks
A circular queue is implemented as a 1D array `Queue` of size 8, with index bounds 1 to 8. The queue is used to store string values.
Three global variables are defined: * `HeadPointer` (INTEGER): stores the index of the element at the front of the queue, initialized to 1. * `TailPointer` (INTEGER): stores the index of the element at the rear of the queue, initialized to 0. * `NumItems` (INTEGER): stores the total number of items currently in the queue, initialized to 0.
Write pseudocode for the function `Enqueue(NewItem : STRING) RETURNS BOOLEAN` to insert an item into the circular queue.
The function should check if the queue is full before attempting insertion. If the queue is full, the insertion fails, and the function returns `FALSE`. If successful, the item is inserted, the pointers and count are updated, and the function returns `TRUE`.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To implement the `Enqueue` operation for a circular queue, several logical steps must be taken: 1. **Check for Full Queue:** The global variable `NumItems` tracks how many elements are currently in the queue. Because the array size is 8, the queue is full when `NumItems` is equal to 8. If so, the function must immediately return `FALSE` and take no further action. 2. **Increment Tail Pointer:** If the queue is not full, the index where the new item is to be added needs to be calculated. The `TailPointer` is incremented by 1. 3. **Wrap-Around Check:** Since it is a circular queue, if `TailPointer` becomes greater than the upper bound of the array (8), it must wrap around and point to the beginning of the array (1). 4. **Insert Item:** The string `NewItem` is written to the array at the position indicated by `TailPointer` (`Queue[TailPointer] <- NewItem`). 5. **Update Count:** The global count of items, `NumItems`, is incremented by 1. 6. **Return Code:** The function returns `TRUE` to signify successful insertion.
PastPaper.markingScheme
Marking scheme (Max 7 marks): * 1 mark: Correct `FUNCTION Enqueue(NewItem : STRING) RETURNS BOOLEAN` header and corresponding `ENDFUNCTION` statement. * 1 mark: Correct validation check for full queue (`NumItems = 8` or equivalent comparison) and returning `FALSE` on this condition. * 1 mark: Incrementing `TailPointer` by 1. * 1 mark: Managing circular boundary wrap-around for `TailPointer` (e.g. `IF TailPointer > 8 THEN TailPointer <- 1` or via modulo operation `TailPointer <- (TailPointer MOD 8) + 1` or similar). * 1 mark: Storing the parameter `NewItem` into the array `Queue` at index `TailPointer`. * 1 mark: Incrementing `NumItems` by 1. * 1 mark: Returning `TRUE` after successful insertion.
PastPaper.question 13 · short_answer
4 PastPaper.marks
A software developer is writing a validation function `ValidateProductCode(Code : STRING) RETURNS BOOLEAN`.
The function validates a product code based on these rules: - It must be exactly 6 characters in length. - The first character must be the uppercase letter 'S'. - The remaining 5 characters must be numeric digits (0 to 9).
The developer designs a test plan to test the validation function.
Complete the test plan table below by providing a suitable example of **Input Data** and the **Expected Outcome** (either **TRUE** or **FALSE**) for each row.
| Row | Test Type | Input Data | Expected Outcome | Description of Test Case | | :--- | :--- | :--- | :--- | :--- | | 1 | Normal | [Row 1 Input] | [Row 1 Outcome] | A standard valid product code. | | 2 | Boundary (Valid) | [Row 2 Input] | [Row 2 Outcome] | A valid product code at the boundary limit of the digits (minimum or maximum possible numeric value). | | 3 | Invalid (Length) | [Row 3 Input] | [Row 3 Outcome] | An invalid product code because of incorrect length. | | 4 | Invalid (Character) | [Row 4 Input] | [Row 4 Outcome] | An invalid product code with correct length but incorrect characters. |
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To validate a product code of exactly 6 characters starting with 'S' followed by 5 digits:
- **Row 1 (Normal)**: Any valid code that lies comfortably within normal bounds, such as `"S12345"` or `"S45321"`. Expected outcome: `TRUE`. - **Row 2 (Boundary)**: Focuses on the extreme/boundary values of the numeric digits. The lowest possible numeric value is `"S00000"` and the highest is `"S99999"`. Expected outcome: `TRUE`. - **Row 3 (Invalid - Length)**: Tests length boundary failures. Any string of length other than 6, such as `"S123"` (too short) or `"S123456"` (too long). Expected outcome: `FALSE`. - **Row 4 (Invalid - Character)**: Tests character rule violations. A string of length 6 that starts with a lowercase letter (e.g., `"s12345"`), starts with a different letter (e.g., `"A12345"`), or contains non-numeric characters in the remaining digits (e.g., `"S12A45"`). Expected outcome: `FALSE`.
PastPaper.markingScheme
1 mark per correct row (comprising both a valid test input and the corresponding correct expected outcome):
- **Row 1**: Any valid 6-character string starting with uppercase 'S' followed by 5 digits (e.g., "S54321") AND Expected Outcome: TRUE / Accept. (1 mark) - **Row 2**: Input "S00000" or "S99999" AND Expected Outcome: TRUE / Accept. (1 mark) - **Row 3**: Any input string where length is not equal to 6 (e.g., "S123", "S123456") AND Expected Outcome: FALSE / Reject. (1 mark) - **Row 4**: Any input string of length 6 starting with a non-'S' character or containing non-digits (e.g., "A12345", "S12B45", "s12345") AND Expected Outcome: FALSE / Reject. (1 mark)
PastPaper.question 14 · written
8 PastPaper.marks
A global 2D array `StudentGrades` of size `[1:100, 1:2]` of type INTEGER stores student records. - Column 1 stores the Student ID. - Column 2 stores the Exam Score.
Write pseudocode for a procedure `SortGrades()` that sorts the elements of the array in **descending order** of their Exam Score (Column 2) using an **efficient bubble sort** algorithm.
An efficient bubble sort must: - Use a boolean flag to stop the sorting process early if a complete pass is made with no swaps. - Reduce the search space (the upper limit of the inner loop) by 1 after each pass, as the smallest element in that pass has reached its correct final position.
Ensure that when two exam scores are swapped, their corresponding student IDs are also swapped.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
An efficient bubble sort algorithm optimizes the standard bubble sort by avoiding redundant checks:
1. **Early Stop Flag**: We introduce a boolean variable `Swapped` initialized to `FALSE` before each pass. If a swap occurs, `Swapped` is set to `TRUE`. If a whole pass completes and `Swapped` is still `FALSE`, the array is fully sorted, and we terminate the loop. 2. **Reducing Inner Loop Limit**: After each pass, the smallest value in the unsorted portion of the array 'bubbles' down to its correct final position at the end. Thus, the inner loop limit (`Last`) is decremented by 1 after each pass (initially set to 99 to prevent index-out-of-bounds when accessing `Index + 1`). 3. **2D Array Integrity**: To ensure that IDs remain matched to their respective exam scores, whenever an exam score is swapped (Column 2), the corresponding Student ID (Column 1) must also be swapped using a parallel swap routine with a separate temporary variable.
PastPaper.markingScheme
Award up to 8 marks for correct implementation of the efficient bubble sort logic:
1. **Outer loop / Termination flag initialization & check (1 mark)**: - Initializes a boolean flag (e.g., `Swapped <- FALSE`) and executes a loop that repeats until `Swapped` remains `FALSE` (or a `WHILE Swapped = TRUE` construct with initial `Swapped <- TRUE`).
2. **Reducing Search Space (1 mark)**: - Decrements the upper boundary of the inner loop by 1 at the end of each pass (e.g., `Last <- Last - 1` or tracking with an outer loop counter).
3. **Inner Loop Setup (1 mark)**: - Sets up a loop (e.g., `FOR Index <- 1 TO Last`) preventing out-of-bounds error (must stop at `Last` where `Last` begins at `99` or equivalent index bounds if checking `Index` against `Index + 1`).
4. **Descending Comparison (1 mark)**: - Correctly compares adjacent elements in Column 2 (Exam Score) for descending order: `StudentGrades[Index, 2] < StudentGrades[Index + 1, 2]`.
5. **Column 2 (Score) Swap (1 mark)**: - Correctly swaps adjacent exam scores using a temporary variable `TempScore`.
6. **Column 1 (ID) Swap (1 mark)**: - Correctly swaps adjacent student IDs using a temporary variable `TempID` inside the same conditional block.
7. **Flag Update (1 mark)**: - Sets the termination flag to `TRUE` (e.g., `Swapped <- TRUE`) inside the conditional block when a swap occurs.
8. **Correct Syntax & Declarations (1 mark)**: - Correct declarations (`DECLARE`) of local variables, procedure definition, and correct closure of control structures (`ENDIF`, `ENDFOR`, `UNTIL`, `ENDPROCEDURE`).
PastPaper.question 15 · pseudocode_writing
6 PastPaper.marks
A software system for an e-commerce platform requires a new module to calculate the final cost of a customer order.
Write pseudocode for the function `ProcessOrder`, which takes three parameters: * `CustomerID` of type `STRING` * `OrderAmount` of type `REAL` * `IsVIP` of type `BOOLEAN`
The function must perform the following logic in sequence: 1. **Validation**: Check if the `CustomerID` is an empty string. If it is empty, the function must immediately return the value `-1.0` to indicate an error. 2. **VIP Discount**: If the customer is a VIP (`IsVIP` is `TRUE`), apply a 10% discount to the `OrderAmount`. 3. **Bulk Discount**: If the calculated amount (after any VIP discount has been applied) is strictly greater than `100.00`, apply an additional 5% discount to that current amount. 4. **Message Output**: Output a confirmation message to the screen in the format: `"Customer [CustomerID]: $[FinalCost]"` where `[CustomerID]` and `[FinalCost]` are replaced with their respective values. 5. **Return**: Return the final calculated cost as a `REAL` value.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
### Step-by-Step Implementation: 1. **Function Header**: Define the function `ProcessOrder` with three parameters: `CustomerID` as `STRING`, `OrderAmount` as `REAL`, and `IsVIP` as `BOOLEAN`. The return type must be declared as `RETURNS REAL`. 2. **Validation**: Check if `CustomerID` is equal to `""` (empty string). If it is, output/return `-1.0` immediately. 3. **VIP Discount**: Store the initial amount in a local variable `FinalCost`. If `IsVIP` is true, calculate `FinalCost <- FinalCost * 0.90` (equivalent to applying a 10% discount). 4. **Bulk Discount**: Check if the updated `FinalCost > 100.00`. If so, calculate `FinalCost <- FinalCost * 0.95` (equivalent to applying a 5% discount). 5. **Output**: Print the required formatted string using `OUTPUT` and appropriate string concatenation or sequential expressions. 6. **Return & Terminate**: Return the calculated `FinalCost` and close the function using `ENDFUNCTION`.
PastPaper.markingScheme
**Marking Scheme (Max 6 marks):**
* **1 Mark**: Correct function header `FUNCTION ProcessOrder(...) RETURNS REAL` specifying the correct parameter names and types. * **1 Mark**: Correct conditional check for empty string `CustomerID` and immediate return of `-1.0`. * **1 Mark**: Correct implementation of the 10% VIP discount (e.g., `FinalCost <- FinalCost * 0.90` or equivalent algebraic formula) guarded by checking if `IsVIP` is true. * **1 Mark**: Correct conditional statement to check if intermediate cost is strictly greater than `100.00` (`> 100.00`) and apply the 5% bulk discount. * **1 Mark**: Correct `OUTPUT` statement matching the structure `"Customer " & CustomerID & ": $" & FinalCost` (allow commas or other correct concatenation syntax). * **1 Mark**: Correct return of final cost value and matching `ENDFUNCTION` terminator.
PastPaper.question 16 · coding
6 PastPaper.marks
A text file, AccessLog.txt, stores records of login attempts. Each line of the file represents a single record and is formatted as a fixed-length string of 25 characters as follows: Characters 1 to 5: User ID (e.g. USR01); Character 6: Comma separator (,); Characters 7 to 15: Date (e.g. 12/05/2023); Character 16: Comma separator (,); Characters 17 to 25: Status (either SUCCESS followed by spaces, or FAILURE followed by spaces, to ensure exactly 9 characters). Write pseudocode for a function CountFailures which takes a specific User ID as a parameter, searches AccessLog.txt, and returns the total number of failed login attempts for that user.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
FUNCTION CountFailures(TargetUserID : STRING) RETURNS INTEGER DECLARE FileLine : STRING DECLARE Count : INTEGER DECLARE CurrentUser : STRING DECLARE CurrentStatus : STRING Count <- 0 OPENFILE "AccessLog.txt" FOR READ WHILE NOT EOF("AccessLog.txt") DO READFILE "AccessLog.txt", FileLine CurrentUser <- MID(FileLine, 1, 5) CurrentStatus <- MID(FileLine, 17, 9) IF CurrentUser = TargetUserID AND CurrentStatus = "FAILURE " THEN Count <- Count + 1 ENDIF ENDWHILE CLOSEFILE "AccessLog.txt" RETURN Count ENDFUNCTION
PastPaper.markingScheme
1 mark: Correct FUNCTION header and ending with correct parameter and return type. 1 mark: Opening AccessLog.txt for READ and closing it before ending. 1 mark: Writing a loop controlled by NOT EOF("AccessLog.txt"). 1 mark: Reading each line from the file using READFILE inside the loop. 1 mark: Correctly isolating User ID using MID(FileLine, 1, 5) and isolating Status using MID(FileLine, 17, 9) (with spaces). 1 mark: Correctly updating the counter when conditions match, and returning the counter at the end.
PastPaper.question 17 · coding
6 PastPaper.marks
A text file, Employees.txt, stores employee records. Each line contains an employee ID of variable length, followed by a single space, followed by a status character ('A' for Active, 'I' for Inactive). The status is always the very last character of the line. Write pseudocode for a procedure FilterActive which reads Employees.txt, filters for employees with an active status, and writes only their employee IDs (without the space or status character) into a new text file named ActiveEmployees.txt.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
PROCEDURE FilterActive() DECLARE Line : STRING DECLARE EmpID : STRING DECLARE Status : STRING DECLARE LineLen : INTEGER OPENFILE "Employees.txt" FOR READ OPENFILE "ActiveEmployees.txt" FOR WRITE WHILE NOT EOF("Employees.txt") DO READFILE "Employees.txt", Line LineLen <- LENGTH(Line) Status <- RIGHT(Line, 1) IF Status = "A" THEN EmpID <- LEFT(Line, LineLen - 2) WRITEFILE "ActiveEmployees.txt", EmpID ENDIF ENDWHILE CLOSEFILE "Employees.txt" CLOSEFILE "ActiveEmployees.txt" ENDPROCEDURE
PastPaper.markingScheme
1 mark: Correct PROCEDURE header and ENDPROCEDURE. 1 mark: Opening Employees.txt for READ and ActiveEmployees.txt for WRITE. 1 mark: Reading the file inside a WHILE NOT EOF("Employees.txt") loop. 1 mark: Extracting the status character using RIGHT(Line, 1). 1 mark: Extracting the Employee ID using LEFT(Line, LineLen - 2) to exclude the space and status. 1 mark: Checking for status 'A', writing the ID to ActiveEmployees.txt, and closing both files.