An original Thinka practice paper modelled on the structure and difficulty of the Jun 2024 (V2) Cambridge International A Level Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
Paper 1 Computer Systems
Answer all questions. Calculators must not be used on this paper.
14 PastPaper.question · 51 PastPaper.marks
PastPaper.question 1 · Short Answer
2 PastPaper.marks
Identify two differences between lossy compression and lossless compression.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Lossless compression compresses files by looking for patterns and representing them more efficiently, meaning no original data is lost and the exact original file can be reconstructed. Lossy compression removes unnecessary or less noticeable data permanently to significantly reduce file size, which means the original file cannot be reconstructed exactly.
PastPaper.markingScheme
Award 1 mark for each distinct difference up to a maximum of 2 marks. - Lossless keeps all data/quality intact whereas lossy permanently removes data/quality. (1 mark) - Lossy achieves a higher compression ratio / smaller file size than lossless. (1 mark) - Lossless allows exact reconstruction of the original file, lossy does not. (1 mark)
PastPaper.question 2 · Short Answer
2 PastPaper.marks
State two characteristics of ransomware.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Ransomware is a type of malicious software designed to block access to a computer system or encrypt its files until a sum of money (a ransom) is paid to the attacker.
PastPaper.markingScheme
Award 1 mark for each valid characteristic up to a maximum of 2 marks: - Encrypts files / locks the system (1 mark) - Demands payment / cryptocurrency ransom to unlock files (1 mark) - Often spreads via malicious email attachments or unpatched software vulnerabilities (1 mark)
PastPaper.question 3 · Short Answer
2 PastPaper.marks
Describe what is meant by an 'interrupt' in a computer system.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
An interrupt is a signal generated by hardware or software that alerts the processor to an event that needs immediate attention. The CPU pauses its current execution, saves its state, and runs an Interrupt Service Routine (ISR) to handle the interrupt before resuming.
PastPaper.markingScheme
Award 1 mark for each point: - It is a signal sent from a device or software to the CPU / processor. (1 mark) - It causes the processor to temporarily pause its current task to handle the event / execute an ISR. (1 mark)
PastPaper.question 4 · Short Answer
2 PastPaper.marks
Describe how a checksum is used to detect errors during data transmission.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
A checksum is an error-detection method. Before transmission, an algorithm is applied to the data block to produce a numerical checksum. This checksum is sent alongside the data. On receipt, the same algorithm is run by the receiver on the incoming data. If the calculated checksum matches the received checksum, the data is assumed correct; otherwise, an error has occurred.
PastPaper.markingScheme
Award 1 mark for each point up to a maximum of 2: - Sender calculates a checksum based on the data and sends it with the block. (1 mark) - Receiver recalculates the checksum and compares it to the received checksum value. (1 mark) - If they do not match, an error is detected / data is retransmitted. (1 mark)
PastPaper.question 5 · Short Answer
2 PastPaper.marks
State the purpose of the Program Counter (PC) register in the CPU architecture.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
In the Von Neumann architecture, the Program Counter (PC) is a dedicated register. Its main job is to hold the memory address of the next instruction that the CPU needs to fetch and execute. Once the instruction is fetched, the PC is incremented to point to the subsequent instruction.
PastPaper.markingScheme
Award 1 mark for each point: - Stores/holds the memory address of the next instruction to be fetched / executed. (1 mark) - Increments (by 1) to point to the next instruction after a fetch. (1 mark)
PastPaper.question 6 · Short Answer
2 PastPaper.marks
State two functions of cookies on a website.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Cookies are small text files downloaded onto a user's computer when visiting a website. They serve several purposes, including storing login states so users don't have to log in on every page, remembering items in a shopping cart, storing user-specific preferences, and tracking user browsing habits for targeted advertising.
PastPaper.markingScheme
Award 1 mark for each valid function up to a maximum of 2 marks: - Storing user preferences / customisation settings (1 mark) - Keeping track of items in a shopping cart / basket (1 mark) - Maintaining a user's login session / state (1 mark) - Tracking browsing behavior / targeted advertising (1 mark) Reject: 'saving passwords' without security qualification, or vague answers like 'saving data'.
PastPaper.question 7 · calculation
4 PastPaper.marks
A digital image is 1024 pixels wide by 768 pixels high. The image has a colour depth of 16 bits.
Calculate the file size of the image in MiB (Mebibytes). Show your working.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To find the file size in MiB: 1. Calculate the total number of pixels: \(1024 \times 768 = 786,432\) pixels. 2. Calculate the file size in bits (using 16-bit colour depth): \(786,432 \times 16 = 12,582,912\) bits. 3. Convert bits to bytes by dividing by 8: \(12,582,912 / 8 = 1,572,864\) bytes (or alternatively, \(2\) bytes per pixel: \(786,432 \times 2 = 1,572,864\) bytes). 4. Convert bytes to KiB by dividing by 1024: \(1,572,864 / 1024 = 1536\) KiB. 5. Convert KiB to MiB by dividing by 1024: \(1536 / 1024 = 1.5\) MiB.
PastPaper.markingScheme
1 mark for calculating total pixels or total bits: \(1024 \times 768 = 786,432\) pixels or \(12,582,912\) bits. 1 mark for converting to bytes: \(1,572,864\) bytes (e.g., showing division by 8 or multiplying pixels by 2). 1 mark for dividing by \(1024 \times 1024\) to convert to MiB (e.g., showing 1536 KiB). 1 mark for the correct final answer: 1.5 MiB (Accept 1.5).
PastPaper.question 8 · calculation
4 PastPaper.marks
An audio track is recorded with a sample rate of 8,192 Hz, a sample resolution of 16 bits, and stereo sound (2 channels). The length of the recording is 120 seconds.
Calculate the file size of the audio recording in MiB (Mebibytes). Show your working.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
To find the file size in MiB: 1. Use the standard formula: \(\text{File size in bits} = \text{sample rate} \times \text{sample resolution} \times \text{duration in seconds} \times \text{number of channels}\). 2. Calculate the size in bits: \(8192 \times 16 \times 120 \times 2 = 31,457,280\) bits. 3. Convert bits to bytes by dividing by 8: \(31,457,280 / 8 = 3,932,160\) bytes. (Alternatively, calculate directly in bytes: \(8192 \times 2\text{ bytes} \times 120 \times 2 = 3,932,160\) bytes). 4. Convert bytes to KiB by dividing by 1024: \(3,932,160 / 1024 = 3840\) KiB. 5. Convert KiB to MiB by dividing by 1024: \(3840 / 1024 = 3.75\) MiB.
PastPaper.markingScheme
1 mark for multiplying sample rate, sample resolution, duration, and channel count: \(8192 \times 16 \times 120 \times 2\) bits or \(8192 \times 2 \times 120 \times 2\) bytes. 1 mark for correct total size in bytes: \(3,932,160\) bytes. 1 mark for division by \(1024\) to get \(3840\) KiB. 1 mark for correct final answer: 3.75 MiB (Accept 3.75).
PastPaper.question 9 · calculation
4 PastPaper.marks
Two 8-bit binary numbers are added together:
`10110100` + `01101101`
a) Calculate the binary sum of these two numbers. Show your working. [2 marks]
b) State whether an overflow error has occurred. Explain your answer. [2 marks]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
a) Perform binary addition: ``` 1 0 1 1 0 1 0 0 (180 in denary) + 0 1 1 0 1 1 0 1 (109 in denary) ----------------- 1 0 0 0 1 0 0 0 1 (289 in denary) ``` Showing carry bits: Carry 1 is generated in columns 2, 3, 4, 5, 6, 7 and past the most significant bit (bit 7).
b) Yes, an overflow error occurred. The original numbers are 8-bit, but their sum (289) is greater than the maximum representable value of 255 in an 8-bit register, resulting in a 9th bit (the leftmost '1') which cannot be stored in an 8-bit register.
PastPaper.markingScheme
Part a: 1 mark for showing correct carry bits or intermediate column additions. 1 mark for the correct 9-bit binary sum: `100010001` (Accept `00010001` with an explicit carry-out of `1` indicated).
Part b: 1 mark for stating that an overflow error has occurred. 1 mark for explaining that the result requires 9 bits to represent, which exceeds the storage limit of an 8-bit register / CPU word size (or explaining that 289 exceeds the maximum 8-bit limit of 255).
PastPaper.question 10 · Explaining System Processes
5 PastPaper.marks
Explain the process of how data is read from an optical disc, such as a CD-ROM, by an optical disc drive.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. A low-powered red laser beam is shone onto the surface of the disc. 2. The disc is spun at a constant speed by a motor. 3. The laser track consists of microscopic pits and lands. 4. Light reflects off the lands but is scattered/not reflected back by the pits or transitions between them. 5. A light-sensing photo-diode detects the changes in intensity of the reflected light. 6. These changes in light reflection are converted into electrical pulses representing binary values (1s and 0s).
PastPaper.markingScheme
Award 1 mark per correct point up to a maximum of 5 marks. - Laser is shone onto the surface of the disc. - The disc is rotated/spun by a motor. - The disc surface has a track made of pits and lands. - Laser light is reflected off the lands / scattered by the pits (or transitions). - A sensor/photoelectric cell detects the reflected light. - The changes in reflected light are converted into electrical signals/binary (1s and 0s). (Note: Accept references to pits/lands representing 0s and transitions representing 1s or vice versa).
PastPaper.question 11 · Explaining System Processes
5 PastPaper.marks
Explain the process of how asymmetric encryption is used to securely transmit a confidential message from Sender A to Receiver B.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. Receiver B generates a public-private key pair where the two keys are mathematically linked. 2. Receiver B sends their public key to Sender A (or publishes it). 3. Receiver B keeps their private key secret. 4. Sender A encrypts the plaintext message using Receiver B's public key, creating ciphertext. 5. The ciphertext is transmitted over the network. 6. Only Receiver B can decrypt the ciphertext using their matching private key to recover the plaintext.
PastPaper.markingScheme
Award 1 mark per correct point up to a maximum of 5 marks. - Receiver B generates a public-private key pair (or public key and private key are mathematically linked). - Receiver B distributes/sends their public key to Sender A (or public key is made public). - Sender A encrypts the message (plaintext) using Receiver B's public key. - The encrypted message (ciphertext) is transmitted. - Receiver B decrypts the ciphertext using their private key. - Only Receiver B's private key can decrypt a message encrypted with Receiver B's public key (ensuring confidentiality).
PastPaper.question 12 · Explaining System Processes
5 PastPaper.marks
Explain the process that occurs when an interrupt signal is received by the CPU during the instruction cycle.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. The CPU checks for any pending interrupts at the end of each Fetch-Decode-Execute (FDE) cycle. 2. If an interrupt is present, the CPU suspends execution of the current process. 3. The current contents of CPU registers (including the Program Counter) are saved onto a stack. 4. The CPU retrieves and executes the Interrupt Service Routine (ISR) / interrupt handler program. 5. Once the ISR is finished, the saved register states are restored from the stack. 6. The CPU resumes the execution of the original process from the point of interruption.
PastPaper.markingScheme
Award 1 mark per correct point up to a maximum of 5 marks. - CPU checks for interrupts at the end of each cycle / instruction. - The execution of the current task/program is suspended/halted. - The state of the current registers / Program Counter (PC) / status register is saved (to a stack). - The CPU loads/runs the specific Interrupt Service Routine (ISR) / interrupt handler. - After the ISR completes, the saved CPU state / registers are restored from the stack. - The CPU resumes the suspended task / program.
PastPaper.question 13 · text-fill
6 PastPaper.marks
Complete the sentences about system software using the correct words from the following list. Some words may be used more than once, and some might not be used at all.
1. An **[1]** is a program or suite of programs that manages computer hardware and system resources. 2. The system software allocates **[2]** to programs currently running, and if this resource becomes full, it may utilize **[3]** located on secondary storage. 3. A software component called a **[4]** acts as a translator between the operating system and an external hardware device. 4. **[5]** refers to small, specialized programs that perform maintenance tasks such as defragmentation or file compression. 5. A signal sent to the CPU from a device or software that temporarily stops execution is called an **[6]**.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
1. **Operating system**: This is the core software that manages hardware resources, processes, and memory. 2. **RAM**: Random Access Memory is the primary memory dynamically allocated to running applications. 3. **Virtual memory**: Used when physical RAM is fully occupied; it temporarily transfers pages of data to secondary storage. 4. **Device driver**: Translate OS instructions into a format the peripheral hardware can understand. 5. **Utility software**: Maintenance tools that optimize, analyze, and configure computer operations. 6. **Interrupt**: A signal to the CPU from software or hardware requesting immediate processing time.
PastPaper.markingScheme
Award 1 mark for each correct term up to a maximum of 6 marks: - [1] Operating system - [2] RAM - [3] Virtual memory - [4] Device driver - [5] Utility software - [6] Interrupt
*Note: Spelling must be accurate to match the word bank. Reject plurals (e.g., 'Device drivers') unless clearly recognizable.*
PastPaper.question 14 · matching
6 PastPaper.marks
Match each statement to the correct error detection method. Tick (✓) only one box for each statement.
| Statement | Parity check | Checksum | Check digit | ARQ | | :--- | :---: | :---: | :---: | :---: | | 1. Uses an extra bit added to a byte of data to make the total count of 1s even or odd. | | | | | | 2. Calculated from a block of data before transmission using an algorithm, and compared at the destination. | | | | | | 3. A validation method where a final digit is calculated from other digits in a barcode or ISBN to catch manual entry errors. | | | | | | 4. Uses positive/negative acknowledgments and timeouts to request the sender to resend corrupted data. | | | | | | 5. Can utilize a 'parity block' to find the exact coordinate of a single corrupted bit to correct it without retransmission. | | | | | | 6. Often used on point-of-sale data entry systems to identify common transposition errors (such as swapping adjacent digits). | | | | |
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
- Statement 1 describes standard even or odd parity verification. (Parity check) - Statement 2 describes generating a numeric block check value sent alongside data transmission. (Checksum) - Statement 3 highlights the use of a calculated extra digit (like Modulo-11) for system entry errors. (Check digit) - Statement 4 outlines the automatic request-to-resend protocol based on acknowledgment signals. (ARQ) - Statement 5 refers to two-dimensional parity, allowing coordinate mapping to correct a bit error. (Parity check) - Statement 6 identifies manual transcription/transposition protection on input codes. (Check digit)
PastPaper.markingScheme
Award 1 mark for each correctly identified statement: - Row 1: Parity check - Row 2: Checksum - Row 3: Check digit - Row 4: ARQ - Row 5: Parity check - Row 6: Check digit
Paper 2 Algorithms, Programming and Logic
Answer all questions. Calculators must not be used on this paper.
Identify the standard two-input logic gate described by each of the following statements: Statement 1: The output is 1 only when both inputs are 0. Statement 2: The output is 1 only when its two inputs are different (one input is 0 and the other is 1). Statement 3: The output is 0 only when both inputs are 1.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Statement 1: The output of a NOR gate is 1 (high) only when all of its inputs are 0. Statement 2: An XOR (Exclusive-OR) gate outputs 1 only when the inputs are different. Statement 3: A NAND gate outputs 0 only when both of its inputs are 1.
PastPaper.markingScheme
1 mark for correctly identifying Statement 1 as NOR. 1 mark for correctly identifying Statement 2 as XOR. 1 mark for correctly identifying Statement 3 as NAND.
Match each of the following Boolean logic expressions to its single standard logic gate equivalent: Expression 1: \(\text{NOT } (A \text{ AND } B)\) Expression 2: \(\text{NOT } (A \text{ OR } B)\) Expression 3: \((A \text{ AND } \text{NOT } B) \text{ OR } (\text{NOT } A \text{ AND } B)\)
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Expression 1 represents a NAND operation. Expression 2 represents a NOR operation. Expression 3 represents an Exclusive-OR (XOR) operation.
PastPaper.markingScheme
1 mark for matching Expression 1 to NAND. 1 mark for matching Expression 2 to NOR. 1 mark for matching Expression 3 to XOR.
Identify the standard logic gate represented by each of the following incomplete truth tables. Truth Table X: [Input A = 0, Input B = 0 -> Output = 0; Input A = 0, Input B = 1 -> Output = 1; Input A = 1, Input B = 0 -> Output = 1; Input A = 1, Input B = 1 -> Output = 0]. Truth Table Y: [Input A = 0, Input B = 0 -> Output = 1; Input A = 0, Input B = 1 -> Output = 0; Input A = 1, Input B = 0 -> Output = 0; Input A = 1, Input B = 1 -> Output = 0]. Truth Table Z: [Input A = 0, Input B = 0 -> Output = 1; Input A = 0, Input B = 1 -> Output = 1; Input A = 1, Input B = 0 -> Output = 1; Input A = 1, Input B = 1 -> Output = 0].
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Truth Table X represents an XOR gate because the output is 1 only when inputs are different. Truth Table Y represents a NOR gate because the output is 1 only when both inputs are 0. Truth Table Z represents a NAND gate because the output is 0 only when both inputs are 1.
PastPaper.markingScheme
1 mark for identifying Truth Table X as XOR. 1 mark for identifying Truth Table Y as NOR. 1 mark for identifying Truth Table Z as NAND.
The following pseudocode is intended to find the highest value in an array of 10 positive integers called Scores, and count how many times this highest value occurs. The array Scores is already populated. There are three errors in this code.
01 Max <- 999 02 Count <- 0 03 FOR Index <- 1 TO 10 04 IF Scores[Index] < Max THEN 05 Max <- Scores[Index] 06 Count <- Count + 1 07 ELSE 08 IF Scores[Index] = Max THEN 09 Count <- Count + 1 10 ENDIF 11 ENDIF 12 NEXT Index
Identify the line number for each of the three errors, explain why it is an error, and write the corrected pseudocode statement.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Error 1: - Line: 01 - Problem: Initializing Max to 999 is too high for a maximum search; it will act as a minimum finder and fail if all scores are lower than 999. - Correction: Max <- 0 (or Max <- Scores[1])
Error 2: - Line: 04 - Problem: The comparison operator is less-than (<) instead of greater-than (>). - Correction: IF Scores[Index] > Max THEN
Error 3: - Line: 06 - Problem: When a new maximum is found, the Count must reset to 1 instead of accumulating the occurrences of old, smaller maximums. - Correction: Count <- 1
PastPaper.markingScheme
- 1 mark: Identifying Line 01 is incorrect and correcting it to Max <- 0 or Max <- Scores[1]. - 1 mark: Identifying Line 04 is incorrect and correcting the comparison operator to >. - 1 mark: Identifying Line 06 is incorrect. - 2 marks: Correctly explaining why Line 06 is incorrect (count must reset to 1 when a new maximum is encountered) and writing the correct assignment (Count <- 1).
Write a pseudocode algorithm that reads names and test scores of 30 students from two pre-populated 1D arrays: Names[1:30] (containing strings) and Scores[1:30] (containing integers). The algorithm must calculate the average score of the class, and then output the names of all students who scored strictly above that average score.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The algorithm first initializes a accumulator variable 'Total' to 0. It then uses a FOR loop running from 1 to 30 to sum all values in the 'Scores' array. After the loop, it calculates the 'Average' by dividing 'Total' by 30. Finally, a second FOR loop runs from 1 to 30, checking each value in the 'Scores' array. If a score is greater than 'Average', the student's name from 'Names' at the same index is output.
PastPaper.markingScheme
- 1 mark: Initializing a running total variable to 0 and correctly looping 30 times to sum all array scores. - 1 mark: Calculating the class average after the first loop by dividing the total by 30. - 1 mark: Using a second loop running from 1 to 30 to inspect each element. - 1 mark: Writing an IF statement that compares Scores[Index] > Average. - 1 mark: Outputting the corresponding student name (Names[Index]) inside the conditional block.
The following function, FindElement, is designed to perform a linear search on a 1D array of 50 elements named Items to look for a specific string value SearchValue. It should return the integer index of the element if found, or -1 if the element is not found. Complete the pseudocode by filling in the five numbered gaps.
FUNCTION FindElement(SearchValue : STRING) RETURNS INTEGER DECLARE Found : BOOLEAN DECLARE Index : INTEGER Found <- FALSE Index <- 1 WHILE (Found = FALSE) AND (Index <= [1]) DO IF Items[Index] = [2] THEN Found <- [3] ELSE Index <- Index + 1 ENDIF ENDWHILE IF Found = TRUE THEN RETURN [4] ELSE RETURN [5] ENDIF ENDFUNCTION
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
The linear search checks each element from index 1 up to the length of the array, which is 50. Therefore, [1] is 50. In the IF condition, we compare each element of the array with the query search parameter, so [2] is SearchValue. If a match is found, the loop termination flag is set to true, so [3] is TRUE. After the loop, if the element was successfully found, we must return its index, so [4] is Index. If not found, we return -1 as specified, so [5] is -1.
PastPaper.markingScheme
Award 1 mark for each correctly filled gap up to 5 marks: - [1] 50 - [2] SearchValue - [3] TRUE (accept True) - [4] Index - [5] -1
Pseudocode: Total <- 0 FOR I <- 1 TO 5 IF Numbers[I] MOD 2 = 0 THEN Total <- Total + Numbers[I] ELSE Total <- Total - Numbers[I] ENDIF NEXT I
Complete the trace table below for this algorithm. Provide the values of the variables for each iteration of the loop.
Columns to track: I | Numbers[I] | Total
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
- Initial: Total is 0. - Iteration 1 (I = 1): Numbers[1] is 3. 3 MOD 2 != 0, so Total becomes 0 - 3 = -3. - Iteration 2 (I = 2): Numbers[2] is 8. 8 MOD 2 == 0, so Total becomes -3 + 8 = 5. - Iteration 3 (I = 3): Numbers[3] is 5. 5 MOD 2 != 0, so Total becomes 5 - 5 = 0. - Iteration 4 (I = 4): Numbers[4] is 12. 12 MOD 2 == 0, so Total becomes 0 + 12 = 12. - Iteration 5 (I = 5): Numbers[5] is 7. 7 MOD 2 != 0, so Total becomes 12 - 7 = 5.
PastPaper.markingScheme
Award 1 mark for each correctly filled row of the trace table corresponding to each value of I from 1 to 5: - Row 1: I = 1, Numbers[I] = 3, Total = -3 - Row 2: I = 2, Numbers[I] = 8, Total = 5 - Row 3: I = 3, Numbers[I] = 5, Total = 0 - Row 4: I = 4, Numbers[I] = 12, Total = 12 - Row 5: I = 5, Numbers[I] = 7, Total = 5
PastPaper.question 8 · Trace Tables
6 PastPaper.marks
A programmer has written the following pseudocode algorithm to process elements of an array named Items. The array contains five elements: Items[1] = 5, Items[2] = 8, Items[3] = 12, Items[4] = 3, Items[5] = 9.
Total <- 10 X <- 1 WHILE X <= 5 DO IF Items[X] < 10 THEN Total <- Total + Items[X] Items[X] <- Items[X] * 2 ELSE Total <- Total - 2 ENDIF X <- X + 2 ENDWHILE
Trace the algorithm by completing the trace table. (State the values in order as they are updated).
| X | Items[1] | Items[3] | Items[5] | Total | |---|---|---|---|---| | | | | | 10 |
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Let's perform a step-by-step dry run of the algorithm: 1. Initially: Total = 10, X = 1. 2. First Loop Iteration (X = 1): X <= 5 is true. Items[1] is 5. Since 5 < 10 is true, Total becomes 10 + 5 = 15. Items[1] becomes 5 * 2 = 10. X is incremented by 2, becoming 3. 3. Second Loop Iteration (X = 3): X <= 5 is true. Items[3] is 12. Since 12 < 10 is false, the ELSE branch runs: Total becomes 15 - 2 = 13. X is incremented by 2, becoming 5. 4. Third Loop Iteration (X = 5): X <= 5 is true. Items[5] is 9. Since 9 < 10 is true, Total becomes 13 + 9 = 22. Items[5] becomes 9 * 2 = 18. X is incremented by 2, becoming 7. 5. Loop termination (X = 7): X <= 5 is false. The loop terminates.
PastPaper.markingScheme
1 mark: Correctly tracing the sequence of X values (1, 3, 5, 7) 1 mark: Correctly updating Items[1] to 10 when X = 1 1 mark: Correctly updating Items[5] to 18 when X = 5 1 mark: Correctly updating Total to 15 when X = 1 1 mark: Correctly updating Total to 13 when X = 3 1 mark: Correctly updating Total to 22 when X = 5
PastPaper.question 9 · SQL Databases
6 PastPaper.marks
A database table named CHOCOLATE is used to store details about products in a confectionery shop. The table structure is shown below:
Field Name | Data Type ProductCode | Text Name | Text CocoaPercentage | Integer Price | Real InStock | Boolean
(a) Write an SQL query to display the Name and Price of all chocolates that have a CocoaPercentage of 70 or more and are currently in stock (InStock is TRUE). The list should be sorted by Price from cheapest to most expensive. [4 marks]
(b) Identify which field in the table is best suited to be the primary key and state one reason why. [2 marks]
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
For part (a), the query requires selecting 'Name' and 'Price' fields from the 'CHOCOLATE' table. The conditions are 'CocoaPercentage >= 70' and 'InStock = TRUE'. Sorting is performed on 'Price' in ascending order (which is the default or specified using ASC). For part (b), ProductCode is the correct primary key because it is a unique identifier for each individual chocolate product record.
PastPaper.markingScheme
Part (a) [Max 4 marks]: - 1 mark: SELECT Name, Price - 1 mark: FROM CHOCOLATE - 1 mark: WHERE CocoaPercentage >= 70 AND InStock = TRUE (Accept InStock = 1 or InStock) - 1 mark: ORDER BY Price (Accept ORDER BY Price ASC)
Part (b) [Max 2 marks]: - 1 mark: Identifying ProductCode as the primary key - 1 mark: Valid explanation (e.g., each product code is unique, prevents duplicates, uniquely identifies each record)
PastPaper.question 10 · practical
15 PastPaper.marks
An aircraft cargo bay is represented by a 2D array, `CargoHold`, which has 6 rows and 4 columns. Each element in the array stores the weight of the cargo in that compartment (in kilograms). An empty compartment is represented by a weight of 0.
Write an algorithm in pseudocode that meets the following requirements: 1. Declares and initialises all elements in the `CargoHold` array to 0. 2. Prompts the user to input a cargo weight for each compartment. Each input must be validated to ensure it is between 0 and 150 (inclusive). If the input is invalid, an error message should be displayed and the user prompted to re-enter the weight until a valid value is provided. 3. Stores the validated weights into the 2D array. 4. Calculates and outputs: - The total weight of all cargo in the hold. - The row number (1 to 6) that has the highest combined total weight of cargo. - The total number of empty compartments in the cargo hold.
You must use pseudocode that follows the standard Cambridge IGCSE pseudocode style.
PastPaper.showAnswersPastPaper.hideAnswers
PastPaper.workedSolution
Here is a complete, standard IGCSE-compliant pseudocode solution:
// Data entry and validation loop FOR Row <- 1 TO 6 FOR Col <- 1 TO 4 REPEAT OUTPUT "Enter weight for Row ", Row, ", Column ", Col, ":" INPUT Weight IF Weight < 0 OR Weight > 150 THEN OUTPUT "Error: Weight must be between 0 and 150 kg." ENDIF UNTIL Weight >= 0 AND Weight <= 150
CargoHold[Row, Col] <- Weight NEXT Col NEXT Row
// Calculations FOR Row <- 1 TO 6 RowWeight <- 0 FOR Col <- 1 TO 4 RowWeight <- RowWeight + CargoHold[Row, Col] IF CargoHold[Row, Col] = 0 THEN EmptyCount <- EmptyCount + 1 ENDIF NEXT Col
TotalWeight <- TotalWeight + RowWeight
IF RowWeight > MaxRowWeight THEN MaxRowWeight <- RowWeight HeaviestRow <- Row ENDIF NEXT Row
Award marks for any of the following points, up to a maximum of 15 marks:
- **Array Declaration & Initialisation (3 marks)** - 1 mark: Declaring the array `CargoHold` as a 2D array of integers with dimensions [1:6, 1:4]. - 1 mark: Outer and inner loops correct (e.g., 1 to 6 and 1 to 4) for initialisation. - 1 mark: Setting every element `CargoHold[Row, Col]` to 0 inside the loops.
- **Input and Validation (4 marks)** - 1 mark: Nested loops used correctly to traverse rows (1 to 6) and columns (1 to 4) for data entry. - 2 marks: Validation check using a validation loop (e.g. `REPEAT...UNTIL` or `WHILE...DO`) ensuring inputs are >= 0 and <= 150, including a suitable error message if invalid. - 1 mark: Storing the validated input correctly in `CargoHold[Row, Col]`.
- **Calculations and Processing (6 marks)** - 1 mark: Declaring and initialising `TotalWeight` and `EmptyCount` to 0. - 1 mark: Incrementing `TotalWeight` by each compartment's weight or by row totals. - 1 mark: Correctly checking if `CargoHold[Row, Col] = 0` and incrementing `EmptyCount` accordingly. - 1 mark: Correctly summing the weight of each individual row inside the row-loop. - 2 marks: Correctly identifying the maximum row weight and saving the index of that row (e.g., comparing `RowWeight > MaxRowWeight` and updating `MaxRowWeight` and `HeaviestRow`).
- **Outputs (2 marks)** - 1 mark: Displaying total weight and empty compartment count with appropriate messages. - 1 mark: Displaying the row number of the heaviest row with an appropriate message.