An original Thinka practice paper modelled on the structure and difficulty of the Jun 2025 OCR AS Level Computer Science - H046 paper. Not affiliated with or reproduced from OCR.
Section H046/01 Computing principles
Answer all questions. 70 marks, 1 hour 15 minutes, no calculator. Asterisked questions assess quality of extended response.
24 Question · 70 marks
Question 1 · Short answer recall
2 marks
A weather station stores a temperature reading as an 8-bit two's complement binary integer.
Show how the denary value -37 is represented in 8-bit two's complement. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
37 in 8-bit binary is 00100101. Invert the bits: 11011010. Add 1: 11011011.
Marking scheme
1 mark for correct positive binary of 37 (00100101) or correct method shown (invert and add 1) 1 mark for correct final answer 11011011 Guidance: Correct answer only scores 2. If the first step is wrong, FT the invert-and-add-1 method for 1 mark. Do not accept sign-and-magnitude 10100101.
Question 2 · Short answer recall
2 marks
A text editor lets a user undo their most recent actions, with the latest action being undone first.
Name the data structure best suited to storing the actions and explain why it is suitable. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
A stack is suitable because items are removed in the reverse of the order they were added: the last action added is the first one removed (LIFO), which matches undoing the latest action first.
Marking scheme
1 mark: Stack 1 mark: ... because it is last in first out // most recent item added is the first removed // push each action and pop to undo Guidance: The second mark is only awarded if stack is named. Do not accept queue.
Question 3 · Short answer recall
2 marks
During the fetch stage of the fetch-decode-execute cycle, the address held in the Program Counter (PC) is copied to another register.
Name this register and state what happens to the PC after the instruction has been fetched. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The address in the PC is copied to the MAR so that the instruction at that address can be fetched from memory. The PC is then incremented to point to the next instruction.
Marking scheme
1 mark: Memory Address Register // MAR 1 mark: PC is incremented // PC is increased by 1 (to point to the next instruction) Guidance: Do not accept MDR or CIR for the first mark. Do not accept 'PC is reset'.
Question 4 · Short answer recall
2 marks
A computer has more running processes than it has processor cores. The operating system uses a round robin scheduling algorithm.
Describe how round robin scheduling shares processor time between the processes. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Each process is allocated the same fixed time slice (quantum) in turn. When the slice ends, an unfinished process is moved to the back of the ready queue and the next process is given the processor.
Marking scheme
1 mark: each process is given a fixed/equal time slice // quantum 1 mark: ... when the time slice ends the process is placed at the back of the queue and the next process runs // processes are served in circular order Guidance: Accept 'finished processes leave the queue'. Do not accept answers describing priority or shortest job first.
Question 5 · Short answer recall
2 marks
An employee at a travel company uses their login to read the booking records of customers they have no work reason to view, then leaves the records unchanged.
Identify the Act that this action breaches and state the offence it describes. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Viewing data without authorisation, even without changing it, is unauthorised access to computer material, an offence under the Computer Misuse Act 1990.
Marking scheme
1 mark: Computer Misuse Act (1990) 1 mark: Unauthorised access to computer material // accessing data without permission/authority Guidance: Accept Data Protection Act 1998 as an additional breach for no marks on its own; the Act named for mark 1 must be the Computer Misuse Act. Second mark may be awarded only if the offence is consistent with the scenario (not modification of data or malware).
Question 6 · Short answer recall
2 marks
A programmer writes a function that takes the radius of a circle and returns its area. The programmer says the function should use a local variable rather than a global variable to hold the area.
State two benefits of using local variables in a subroutine. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
A local variable only exists inside the subroutine, so other code cannot alter it by mistake, names can be reused without clashing, and its memory is released when the subroutine finishes.
Marking scheme
1 mark per bullet up to a maximum of 2: - Cannot be accidentally modified by other parts of the program // reduces side effects - Same identifier can be reused elsewhere without conflict - Memory is released when the subroutine ends // uses memory only while needed - Subroutine is self-contained so easier to reuse/test/debug Guidance: Do not accept 'faster' or 'easier to write' without justification.
Question 7 · Short answer recall
2 marks
A sorted array contains 100 customer reference numbers. A programmer chooses to use a binary search rather than a linear search to find a given reference number.
Explain why the binary search is likely to be quicker, and state one condition that must be true of the data for it to work. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Binary search discards half of the remaining items after each comparison, so it needs far fewer comparisons than checking items one by one. It only works if the data is already sorted.
Marking scheme
1 mark: Halves the number of items to search each comparison // fewer comparisons needed on average (than checking each item in turn) 1 mark: Data must be sorted (in order) Guidance: Do not accept 'it is faster' on its own for the first mark.
Question 8 · Short answer recall
2 marks
A train company displays a simplified map of its network showing stations as labelled dots joined by straight lines, with no accurate distances or geography.
State what is meant by abstraction and give one detail from reality that has been removed from this map. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Abstraction means hiding or removing unnecessary detail so that only the features relevant to the task remain. The map omits details such as the true distance between stations or the actual shape of the track.
Marking scheme
1 mark: Removing/hiding unnecessary detail (leaving only the essential features for the purpose) 1 mark: Suitable detail removed from the map e.g. real distances, track curves, geography, landmarks, scale Guidance: Second mark may be awarded independently of the first.
Question 9 · short_answer
2 marks
A weather station stores a temperature reading as an 8-bit two's complement binary integer.
Show the 8-bit two's complement representation of the denary number \(-37\). [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
37 in binary is 00100101. Invert the bits: 11011010. Add 1: 11011011.
Marking scheme
1 mark: correct positive binary 00100101 (or inversion shown as 11011010) // evidence of invert and add 1. 1 mark: correct answer 11011011. Guidance: Correct answer only scores 2. FT one mark if the positive binary is wrong but the method is applied correctly.
Question 10 · short_answer
2 marks
A programmer writes a procedure that receives a parameter and changes its value.
Explain the difference between passing a parameter by value and passing it by reference. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
With by value, the subroutine works on a copy of the argument, so any change is lost when the subroutine ends. With by reference, the subroutine is given the address of the original variable, so changes alter the original.
Marking scheme
1 mark per bullet up to 2: - By value, a copy of the data is passed // the original is not changed by the subroutine - By reference, the address/location of the variable is passed // the subroutine works on the original variable - ... so changes made inside the subroutine are kept after it ends Guidance: Both methods must be addressed for 2 marks. Accept 'pointer' for address.
Question 11 · short_answer
2 marks
A computer is running a video editor and a music player at the same time. The operating system uses the round robin scheduling algorithm.
Describe how round robin scheduling shares the processor between the two programs. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The scheduler gives each process a fixed time slice on the CPU. When the slice expires the process is pre-empted and placed at the back of the ready queue, and the next process in the queue gets the CPU. This repeats in a cycle.
Marking scheme
1 mark per bullet up to 2: - Each process is allocated a fixed time slice // quantum - When the time slice ends the process is moved to the back of the (ready) queue - The next process in the queue is then given the processor // processes are executed in a cycle/turn Guidance: Do not accept 'the shortest job runs first'.
Question 12 · short_answer
2 marks
During the fetch stage of the fetch-decode-execute cycle, the address held in the Program Counter (PC) is used to obtain the next instruction.
Describe what happens to the contents of the PC and the Memory Address Register (MAR) at the start of the fetch stage. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The address in the PC is copied to the MAR so that memory knows which location to read. The PC is then incremented by one so it points to the following instruction.
Marking scheme
1 mark: the address/contents of the PC is copied to the MAR. 1 mark: the PC is incremented (by 1) // updated to point to the next instruction. Guidance: Do not accept 'the PC is moved' if the PC is said to be emptied. Allow the increment to be described as happening at any point in the fetch stage.
Question 13 · short_answer
2 marks
A delivery company uses an automated system to decide which drivers receive extra shifts, based on past performance data.
Identify two ethical concerns about using automated decision making in this way. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Automated systems learn from historical data, which may contain bias. It can also be unclear who is responsible for an unfair decision, and drivers may not understand or be able to challenge it.
Marking scheme
1 mark per bullet up to 2: - Bias in the data or algorithm leading to unfair decisions - Lack of accountability // unclear who is responsible for errors - Lack of transparency // drivers cannot see how decisions are made - No human oversight // no way to appeal or challenge a decision - Loss of the personal context a human manager would consider Guidance: Do not accept answers that only say 'it might be wrong' without development. Do not accept two rewordings of the same point.
Question 14 · short_answer
2 marks
A greenhouse alarm sounds (Q) when the door is open (D) AND the heater is on (H), or when the sensor fault flag (F) is set.
Write a Boolean expression for Q in terms of D, H and F. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The door open and heater on conditions are combined with AND. The result is combined with the fault flag using OR.
Marking scheme
1 mark: D AND H (or equivalent symbol) combined correctly. 1 mark: ... OR F with the correct structure. Guidance: Accept any valid notation, e.g. (D.H)+F or (D ∧ H) ∨ F. Brackets are not required as AND takes precedence, but do not accept D AND (H OR F).
Question 15 · Extended response, levels of response
9 marks
*A regional bus company, Harbourline Buses, plans to replace its human route planners with an artificial intelligence system. The system will decide timetables automatically. It will also use data from passengers' travel cards and from cameras and GPS trackers fitted to the buses to monitor where passengers travel and how drivers behave.
Discuss the moral, social and ethical issues the company should consider before introducing the system. In your answer you should refer to: - the effect on the company's workforce - automated decision making - the monitoring of passengers and drivers and the analysis of personal information - the legal responsibilities of the company in how it handles the data collected.
[9]
Show answer & marking schemeHide answer & marking scheme
Worked solution
A strong answer would discuss:
Workforce: route planners may lose their jobs (deskilling, unemployment), though new roles in maintaining the system and data analysis may be created; the company saves money, and the AI can work continuously and produce timetables faster. Retraining could be offered.
Automated decision making: the AI may produce timetables that favour profitable routes and leave rural or low-income areas poorly served; it may be biased by the data it was trained on; decisions may be hard to explain or challenge; there is no human judgement for unusual events such as festivals or road closures; but it can be consistent and can optimise using large amounts of data. Someone must be accountable when it makes a poor decision.
Monitoring and personal information: tracking journeys reveals where people live, work and worship, which is intrusive; passengers may not have consented; drivers may feel constantly watched, leading to stress; but monitoring can improve safety, deter crime and allow better service planning. Data could be sold or misused, and a data breach could harm individuals.
Legal: the Data Protection Act 1998 requires data to be fairly and lawfully processed, used only for stated purposes, adequate and not excessive, accurate, not kept longer than needed, kept secure and available to the data subject on request. The Computer Misuse Act 1990 is relevant to unauthorised access to the system or data by hackers or staff. The Regulation of Investigatory Powers Act 2000 is relevant if communications are intercepted or monitored.
Conclusion: for example, the benefits (efficiency, safety) can outweigh the risks if staff are retrained, a human can review automated decisions, data collection is minimised and passengers are informed. Any justified conclusion is accepted.
Marking scheme
Levels of response. Mark by best fit. The indicative content is not exhaustive. Any recommendation is accepted if justified.
Level 3 (7-9 marks): Thorough knowledge and understanding of the moral, social and ethical issues, with detailed reference to the bus company scenario. Covers all four bullet areas, with both benefits and risks considered. A reasoned, balanced conclusion or judgement is reached. The line of reasoning is well structured and sustained. Specialist terminology is used accurately.
Level 2 (4-6 marks): Good knowledge of several issues, with some application to the scenario. At least two bullet areas are covered, with some attempt at balance or evaluation, though it may be one-sided or lack a conclusion. The line of reasoning is mostly clear.
Level 1 (1-3 marks): Basic, generic knowledge of one or two issues with little or no application to the scenario. Points are listed or asserted without development or balance. Little structure.
Level 0 (0 marks): No response worthy of credit.
Indicative content: AO1 (knowledge): loss of jobs/deskilling vs new roles; automated decision making; AI bias; surveillance/monitoring; personal data analysis; Data Protection Act 1998 principles (fair and lawful, specified purpose, adequate/not excessive, accurate, not kept longer than necessary, secure, subject access); Computer Misuse Act 1990 (unauthorised access); Regulation of Investigatory Powers Act 2000 (interception/monitoring of communications). AO2 (application): rural routes neglected; passenger journeys reveal home/work; drivers monitored by cameras and GPS leading to stress or improved safety; retraining of route planners; accountability if the timetable fails; security of stored travel card data. AO3 (evaluation): weighing efficiency, cost and safety against job losses, privacy and fairness; suggesting safeguards (human oversight, consent, data minimisation, encryption, retention limits) and reaching a justified conclusion.
Guidance: Do not award Level 3 without a conclusion or evaluation. Cap at Level 2 if there is no reference to the scenario. Do not credit named legislation other than as relevant to the points made.
Question 16 · Extended response, levels of response
9 marks
*Priya is setting up a small video-editing studio. She uses one computer running a multi-tasking operating system. While she renders a long video, she also has a web browser, a music player and a file backup utility open. The computer has 8 GB of RAM, and she often finds that it slows down badly when she opens large project files.
Discuss how the operating system manages the programs and memory on Priya's computer. In your answer you should refer to: - how a scheduling algorithm could share processor time between the programs - how memory management techniques, including virtual memory, are used when RAM is limited - the role of interrupts and device drivers while she works - why the computer may slow down when many large files are open.
[9]
Show answer & marking schemeHide answer & marking scheme
Worked solution
A strong answer would discuss:
Scheduling: a multi-tasking OS shares the processor between the render, browser, music player and backup utility. In round robin each process gets a fixed time slice, then is pre-empted and placed at the back of the queue, so all programs appear to run at once; it is fair but has context switch overhead, and the render may take longer. A multi-level feedback queue could favour interactive programs such as the browser and move long CPU-bound jobs such as rendering to lower priority queues. First come first served would make the other programs wait for the render to finish, which is unsuitable. Shortest job first risks starving the long render.
Memory management: the OS allocates RAM to each program and keeps them separate. Paging divides memory into fixed-size pages/frames; segmentation uses variable-size logical segments. When RAM is full, virtual memory uses part of secondary storage to hold pages not currently needed, which are swapped in when required. This lets Priya run programs larger than the available RAM, but the disk is much slower than RAM.
Interrupts and drivers: when she presses a key, moves the mouse or the backup finishes writing, the device sends an interrupt. At the end of the fetch-decode-execute cycle the processor checks for interrupts, compares priorities, saves the registers/state of the current process and runs the interrupt service routine, then restores state and resumes. Device drivers translate between the OS and hardware such as the keyboard, graphics card and storage so the OS can use them without knowing their details.
Slowdown: large project files fill RAM, so many pages are swapped between RAM and disk. If excessive, this is thrashing, and the CPU spends more time waiting for the disk than running programs. More RAM, closing programs or using a faster SSD would help.
Conclusion: any justified judgement, e.g. the OS manages resources well, but the limited RAM is the main bottleneck, so upgrading RAM would be the best improvement.
Marking scheme
Levels of response. Mark by best fit. The indicative content is not exhaustive. Any recommendation is accepted if justified.
Level 3 (7-9 marks): Thorough and accurate knowledge of scheduling, memory management, interrupts and drivers, applied clearly to Priya's computer. All four bullet areas are addressed, with a reasoned explanation of why slowdown happens and a justified judgement or conclusion. The line of reasoning is logical and sustained.
Level 2 (4-6 marks): Good knowledge of at least two areas, with some application to the scenario. Some explanation, but may be unbalanced or lack a conclusion. The line of reasoning is mostly clear.
Level 1 (1-3 marks): Basic recall of one or two terms, with little explanation or application. Descriptions may be vague or generic.
Level 0 (0 marks): No response worthy of credit.
Indicative content: AO1 (knowledge): round robin, time slice, FCFS, SJF, shortest remaining time, multi-level feedback queues; pre-emption; paging and segmentation; virtual memory; interrupts, priorities, ISR; the processor checking for interrupts in the fetch-decode-execute cycle; device drivers as software that lets the OS communicate with hardware. AO2 (application): render job as long CPU-bound task; browser/music player as interactive tasks; large project files filling 8 GB RAM; saving registers/state when an interrupt occurs from keyboard or mouse; backup utility using the disk at the same time. AO3 (evaluation): comparing the suitability of scheduling algorithms for this mixture of tasks; weighing the benefit of virtual memory against the speed cost of disk access (thrashing); recommending improvements such as extra RAM, an SSD or closing programs, with justification.
Guidance: Do not award Level 3 without evaluation/conclusion. Cap at Level 2 if there is no reference to the scenario. Accept alternative valid scheduling algorithms if justified. Do not accept 'virtual memory is extra RAM' without mention of secondary storage.
Question 17 · Code-writing task (array handling)
6 marks
A community swimming pool records the number of visitors on each of 28 consecutive days. The counts are stored in a zero-based one-dimensional array called visitors, for example:
array visitors[28]
Write a function named analyseVisits that takes the array visitors as a parameter and: - prints the number of days on which fewer than 20 visitors were recorded - returns the index of the day with the highest number of visitors. If two or more days share the highest number, the index of the first of these days is returned.
You may write your answer in pseudocode or a high-level programming language. [6]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The function must visit every element once. A variable best holds the index of the largest value so far, starting at index 0. A counter quiet starts at 0 and is increased whenever the current element is below 20. A strict greater-than comparison means the first of any tied maximum days is kept. After the loop the count is printed and best is returned.
Example solution:
function analyseVisits(visitors) best = 0 quiet = 0 for i = 0 to 27 if visitors[i] < 20 then quiet = quiet + 1 endif if visitors[i] > visitors[best] then best = i endif next i print(quiet) return best endfunction
Marking scheme
1 mark per bullet up to a maximum of 6 marks: - Function declared with the array as a parameter and a return statement // returns a value (1) - Initialising the best index (or best value) to the first element / index 0 (1) - Initialising the counter to 0 before the loop (1) - Loop that visits every element from index 0 to 27 // uses length of array (1) - Compares an element with the current maximum using > (not >=) and updates the best index when larger (1) - Increments the counter when an element is < 20, then prints the counter after the loop and returns the index (1)
Guidance: Accept 1-based loops only if consistently applied to a 1-based array and returned index is consistent with the question. Accept any loop type (for / while). Accept storing the maximum value as well as the index provided the index is returned. Do not accept <= 20 for the count. Do not award the comparison mark for >= as this returns the last tied day. Do not award the final mark if the print is inside the loop. Accept Python-style or other high-level language syntax if used consistently. The example solution is only one possible answer.
Question 18 · Code-writing task (array handling)
6 marks
A small theatre stores its seat bookings for one performance in a two-dimensional array called seats with 5 rows and 8 columns (both zero-based). Each element holds the string "X" if the seat is booked or "-" if the seat is free.
array seats[5, 8]
Write a function named emptiestRow that takes the array seats as a parameter and: - counts the number of free seats in each row - returns the row number of the row with the most free seats. If rows tie, the lowest row number is returned.
You may write your answer in pseudocode or a high-level programming language. [6]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Use nested loops: the outer loop moves through the rows and the inner loop through the columns. The free-seat counter is reset to 0 at the start of each row. After each row has been counted it is compared with the best count so far using a strict greater-than so the lowest row wins ties. The best row is returned after both loops finish.
Example solution:
function emptiestRow(seats) bestRow = 0 bestCount = -1 for r = 0 to 4 count = 0 for c = 0 to 7 if seats[r, c] == "-" then count = count + 1 endif next c if count > bestCount then bestCount = count bestRow = r endif next r return bestRow endfunction
Marking scheme
1 mark per bullet up to a maximum of 6 marks: - Function declared with the array as a parameter and returns a row number (1) - Outer loop through all 5 rows (1) - Inner loop through all 8 columns, nested inside the outer loop (1) - Correct test of an element for a free seat (equal to "-") and counter incremented (1) - Row counter reset to 0 for each row, inside the outer loop but before the inner loop (1) - Compares row count with best so far using > and updates the best row (and best count); returns the best row after the loops (1)
Guidance: Accept [r][c] or [r,c] indexing. Accept any loop type. Accept the best count initialised to 0 provided ties still give the lowest row (strict >) // accept initialisation using row 0 first. Do not award the reset mark if the counter is initialised once before the outer loop. Do not award the final mark for >= as this returns the highest tied row. Accept Python-style or other high-level language syntax if used consistently. The example solution is only one possible answer.
Question 19 · Calculation and logic (binary, K-map, truth table)
2 marks
A sensor stores the temperature offset of -45 as an 8-bit binary number using two's complement.
Show the 8-bit two's complement representation of -45. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
45 in 8-bit binary is 00101101. Invert every bit to get 11010010. Add 1 to get 11010011.
Marking scheme
1 mark: correct positive binary 00101101 (or bits inverted 11010010) shown as working. 1 mark: correct final answer 11010011. Guidance: Correct answer alone scores 2. Allow FT for the final mark if the inversion/addition is correct from an incorrect 8-bit positive value. Do not accept sign-and-magnitude 10101101 (scores 0).
Question 20 · Calculation and logic (binary, K-map, truth table)
2 marks
Two unsigned 8-bit binary integers are stored in registers.
Add 01101101 and 00111011 and give the 8-bit result. Show your working. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Adding column by column from the right with carries: 01101101 + 00111011 = 10101000. Check in denary: 109 + 59 = 168 = 10101000 in binary. No overflow occurs because 168 is less than 256.
Marking scheme
1 mark: evidence of correct binary addition method (carries shown, or correct partial sum). 1 mark: correct answer 10101000. Guidance: Correct answer only scores 2 if the answer is fully correct. A denary check alone showing 109 + 59 = 168 with a correct binary answer is acceptable working. Maximum of 1 if the answer is not 8 bits long.
Question 21 · Calculation and logic (binary, K-map, truth table)
2 marks
A colour code in a web page style sheet is stored as the hexadecimal value 9E.
Convert the hexadecimal value 9E into denary. Show your working. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The hexadecimal digit 9 is in the 16s column, so 9 x 16 = 144. The digit E represents 14, so 14 x 1 = 14. Total: 144 + 14 = 158.
Marking scheme
1 mark: 9 x 16 = 144 (or 144 seen) and E = 14. 1 mark: correct answer 158. Guidance: Correct answer only scores 2. Accept conversion via binary 10011110 if it leads to 158.
Question 22 · Calculation and logic (binary, K-map, truth table)
2 marks
A greenhouse vent opens (Q = 1) according to the Boolean expression:
Q = NOT A AND (B OR C)
Complete the truth table for four combinations of the inputs. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Group the two 1s in the column BC = 11 (rows A = 0 and A = 1): this gives B AND C. Group the two adjacent 1s in row A = 1 (columns BC = 11 and 10): B stays 1, C changes, so this gives A AND B. Combining the groups: Q = (B AND C) OR (A AND B).
Marking scheme
1 mark: B AND C (from the vertical group). 1 mark: A AND B (from the horizontal group), correctly combined with OR. Guidance: Accept B.C + A.B, or the terms in any order. Do not accept an unsimplified sum of minterms for full marks (maximum 0 if no grouping is evident). Accept A.B + B.C written with an overbar notation where relevant.
Question 24 · Calculation and logic (binary, K-map, truth table)
2 marks
A programmer stores the 8-bit binary value 10110111 as an unsigned integer.
Convert 10110111 into hexadecimal. Show your working. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Split into two nibbles: 1011 and 0111. 1011 is 11 in denary, which is B in hexadecimal. 0111 is 7. The result is B7.
Marking scheme
1 mark: correct split into nibbles 1011 and 0111 (or each nibble correctly converted). 1 mark: correct answer B7. Guidance: Correct answer only scores 2. Accept lower case b7. Allow FT if one nibble is converted incorrectly (maximum 1).
Ready to test yourself?
Turn these notes into exam-style practice. Get unlimited AI questions on this topic with instant marking and explanations.
Answer all questions. 70 marks, 1 hour 15 minutes, no calculator. Extra answer space at the end of the booklet.
21 Question · 69 marks
Question 1 · short_answer
2 marks
The following algorithm is written in pseudocode.
01 total = 0 02 for i = 1 to 5 03 if i MOD 2 == 1 then 04 total = total + i * i 05 endif 06 next i 07 print(total)
State the value that is output by line 07 and identify which values of i cause line 04 to execute. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
i = 1, 3 and 5 are odd, so line 04 runs for these. total = 1 + 9 + 25 = 35.
Marking scheme
1 mark: i = 1, 3, 5 identified (all three needed). 1 mark: output 35. Guidance: Correct answer only for 35. Do not accept 'odd numbers' alone for the first mark unless values are listed.
Question 2 · short_answer
2 marks
An array holds the values [6, 3, 9, 2, 5]. A bubble sort is used to sort it into ascending order.
Show the contents of the array after the first complete pass of the bubble sort, and state how many swaps were made during that pass. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Compare 6,3: swap -> 3,6,9,2,5. Compare 6,9: no swap. Compare 9,2: swap -> 3,6,2,9,5. Compare 9,5: swap -> 3,6,2,5,9. Three swaps in total.
Marking scheme
1 mark: array [3, 6, 2, 5, 9]. 1 mark: 3 swaps. Guidance: FT the number of swaps from an incorrect array if consistent with the candidate's working.
Question 3 · short_answer
2 marks
An empty stack is used by a text editor to store undo steps. The following operations are performed in order:
push(4) push(7) push(1) pop() push(9) pop()
State the two values returned by the pop operations, in the order they were returned, and the contents of the stack at the end, starting from the bottom. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
A stack is last in first out. The first pop removes 1 (the last item added). 9 is then pushed and immediately popped. Remaining: 4 at the bottom and 7 on top.
Marking scheme
1 mark: values returned 1 then 9 in that order. 1 mark: remaining contents 4, 7 with 4 at the bottom. Guidance: Do not accept 9, 1. Accept 7 identified as the top item.
Question 4 · short_answer
2 marks
Convert the denary number -19 into an 8-bit binary number using two's complement. Show your working. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
19 in 8-bit binary is 00010011. Invert the bits: 11101100. Add 1: 11101101.
Marking scheme
1 mark: method, e.g. 19 = 00010011 and inverted and 1 added // evidence of correct positive value. 1 mark: 11101101. Guidance: Correct answer scores both marks. Allow the method mark if the final answer has a single slip.
Question 5 · short_answer
2 marks
A developer is testing a program that calculates delivery charges for an online shop.
Describe one difference between black-box testing and white-box testing. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Black-box testing treats the program as unknown internally and checks outputs against expected results for given inputs. White-box testing designs test data from the source code so that each branch or path is executed.
Marking scheme
1 mark per bullet, max 2: - Black-box: tester has no knowledge of the internal code // tests inputs and expected outputs only - White-box: tester knows the internal code // tests designed to cover paths/branches/statements Guidance: Both sides must be contrasted for 2 marks; a single correct description of one type scores 1.
Question 6 · short_answer
2 marks
A computer uses a round robin scheduling algorithm to share the processor between several processes.
Explain how round robin scheduling decides which process uses the processor. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Processes wait in a queue. The process at the front runs for a fixed time slice (quantum). If it has not finished it is moved to the back of the queue and the next process is given the processor.
Marking scheme
1 mark per bullet, max 2: - Each process is allocated a fixed time slice // quantum - When the time slice ends the process is pre-empted and placed at the back of the queue - The next process in the queue is then given the processor // processes are served in circular order Guidance: Do not accept 'shortest process first'.
points = 10 extra = 5 addBonus(points, extra) print(points) print(extra)
State the two values that are output and explain why the value of extra is not changed. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
points is passed by reference, so the procedure alters the original and it becomes 15. extra is passed by value, so the procedure works on a copy; setting bonus to 0 does not affect extra, which remains 5.
Marking scheme
1 mark: outputs 15 and 5 in that order. 1 mark: extra passed by value // a copy is made // the original is not changed. Guidance: Mark in pairs is not required; the explanation mark can be awarded independently.
Question 8 · short_answer
2 marks
A bank uses an automated system to decide whether customers are offered a loan.
Describe one ethical concern about the use of automated decision making in this situation. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Automated systems follow rules or learned patterns that may reflect bias in historical data. This can unfairly disadvantage groups of customers, and with no human involved there may be no clear way to appeal or understand the decision.
Marking scheme
1 mark per point ... development, max 2: - Possible bias in the data or rules ... leading to unfair refusal for certain groups - Lack of transparency // no human oversight ... customers cannot understand or challenge the decision - Errors in data ... wrongly refused loans with no easy correction Guidance: Mark in pairs; a development only scores if its point is made. Do not accept 'it is quicker' as a concern.
Question 9 · short_answer
2 marks
A programmer writes the following pseudocode.
1 x = 47 2 total = 0 3 while x > 0 4 total = total + (x MOD 10) 5 x = x DIV 10 6 endwhile 7 print(total)
State the value that is output by line 7 and the number of times line 4 is executed. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
First pass: x = 47, total = 0 + 7 = 7, x = 4. Second pass: total = 7 + 4 = 11, x = 0. The loop condition x > 0 is now false, so the loop ends after 2 passes and 11 is printed.
Marking scheme
1 mark: output of 11. 1 mark: line 4 executed 2 times. Accept 'twice'. Do not accept 3. Each mark is independent.
Question 10 · short_answer
2 marks
A library stores 1000 book reference numbers in an array. Maria wants to use a binary search to find a reference number.
State one precondition that must be true of the array before a binary search can be used, and explain why a binary search is usually faster than a linear search on this data. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Binary search compares with the middle item and discards half of the list depending on whether the target is higher or lower. This only works if the data is in order. Each comparison halves the number of items left, whereas a linear search may check every item in turn.
Marking scheme
1 mark: the array/data must be sorted // in order. 1 mark: it halves the search space each comparison // discards half of the remaining items // fewer comparisons than checking items one by one. Do not accept 'it is quicker' alone. Do not accept unique values as the precondition.
Question 11 · short_answer
2 marks
An empty stack has the following operations performed on it in order:
State the value returned by the final pop() and the contents of the stack after all operations have been performed. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
After push(5), push(8): [5, 8]. pop removes 8: [5]. push(2), push(9): [5, 2, 9]. pop removes 9: [5, 2]. Final pop removes and returns 2, leaving [5].
Marking scheme
1 mark: final pop returns 2. 1 mark: stack contains only 5. FT: if the first answer is wrong but the stack contents are consistent with a stated error, award the second mark only if the working is shown.
Question 12 · short_answer
2 marks
Represent the denary number -45 as an 8-bit two's complement binary integer. Show your working. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
45 in 8-bit binary is 00101101. Invert every bit: 11010010. Add 1: 11010011. Check: -128 + 64 + 16 + 2 + 1 = -45.
Marking scheme
1 mark: method, e.g. 45 as 00101101 and inverted and 1 added // correct positive binary 00101101. 1 mark: correct answer 11010011. Correct answer only gets both marks. If the answer is wrong, award 1 mark for 00101101 or 11010010 shown in working.
Question 13 · short_answer
2 marks
A games studio is testing a new puzzle app. One tester checks the app by entering inputs and comparing the results with the specification, without looking at the source code. Another tester examines the code and designs tests so that every branch is executed.
Name the testing strategy used by each tester. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Testing inputs against expected outputs without knowledge of the code is black-box testing. Designing tests from the internal structure of the code so all paths and branches are covered is white-box testing.
Marking scheme
1 mark: black-box testing for the first tester. 1 mark: white-box testing for the second tester. Accept 'glass-box' or 'clear-box' for white-box. Do not accept alpha or beta testing.
Question 14 · Extended response, levels of response
9 marks
* A community library is writing a program to manage its catalogue of 40 000 book records. Each record holds a unique catalogue number, a title and an author. Staff need to:
- look up a single book quickly by its catalogue number at the issue desk - print a full list of books ordered by catalogue number once a week, after new books have been added at the end of the existing list.
The developer is considering linear search and binary search for the look-up, and bubble sort and insertion sort for the weekly ordering.
Discuss which algorithms the developer should choose. In your answer you should:
- describe how each of the search algorithms works and the condition each needs the data to meet - compare the suitability of the two search algorithms for this catalogue - compare the suitability of the two sorting algorithms for the weekly task, considering that only a few new records are added to an already ordered list - reach a justified conclusion about which algorithms to use. [9]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Linear search checks each record in turn from the start, comparing its catalogue number with the target, until a match is found or the end of the list is reached. It does not need the data to be ordered. Binary search compares the target with the middle record, discards the half that cannot contain the target, and repeats on the remaining half until the item is found or no records remain. It needs the data to be sorted on the key (catalogue number) and to be directly accessible by index.
For 40 000 records, linear search may need up to 40 000 comparisons (about 20 000 on average), which is slow at a busy issue desk. Binary search halves the search space each time, so it needs at most about 16 comparisons (since 2^16 = 65 536 > 40 000). Linear search is simpler and works even if the list is unordered, but since the list is sorted weekly anyway, binary search is suitable. A drawback is that the list must be sorted before searching, and the newly added books at the end are unordered until the weekly sort, so they could be checked with a linear search of the few new records.
Bubble sort repeatedly compares adjacent items and swaps them if out of order, making passes until a pass has no swaps. Insertion sort takes each item in turn and shifts it left into its correct position within the already sorted section. When only a few new records have been added to an ordered list, insertion sort only has to move those few items and makes very few comparisons for the already-ordered part. Bubble sort needs at least one full pass over 40 000 items to confirm order, and small values near the end move only one place per pass, so many passes may be needed. Both are simple to code and sort in place, but both are slow for large random data.
Conclusion: use binary search for look-ups and insertion sort for the weekly ordering (with a justified alternative such as a merge-based approach not required).
Marking scheme
Levels of response. Indicative content is not exhaustive; any recommendation is accepted if justified.
AO1 (knowledge) indicative content: - Linear search: checks each item in turn until found or end reached // works on unordered data - Binary search: compares with middle item, discards half, repeats // requires data to be sorted - Bubble sort: compares adjacent items and swaps, repeated passes until no swaps - Insertion sort: takes each item and inserts it into the correct place in the sorted part
AO2 (application) indicative content: - 40 000 records: linear search up to 40 000 comparisons vs binary search about 16 comparisons - Issue-desk look-ups need to be fast, so many searches are performed - Data is nearly sorted with a few records added at the end: insertion sort needs few shifts/comparisons - Bubble sort needs at least one full pass and small items at the end move one place per pass, so more passes - New unsorted records mean binary search only valid after the weekly sort (or search new records linearly)
AO3 (evaluation) indicative content: - Linear search is simpler and needs no sorted data, but too slow at this size - Binary search needs sorted data and index access, with the cost of keeping the list ordered - Both sorts are simple and in place but inefficient for large random data; for near-sorted data insertion sort is better - Justified conclusion, e.g. binary search + insertion sort
Band 3 (7-9 marks): Thorough knowledge of all four algorithms, accurately applied to the library context. Balanced discussion comparing both pairs, with evaluation and a justified conclusion. Line of reasoning is logical, coherent and sustained throughout. Band 2 (4-6 marks): Good knowledge of most algorithms with some application to the context. Some comparison, but may be unbalanced (for example covering searching more than sorting) or with limited evaluation or conclusion. Line of reasoning mostly clear. Band 1 (1-3 marks): Basic knowledge of some algorithms, possibly descriptions only with little or no application to the scenario. Little or no comparison or conclusion. Limited line of reasoning. Band 0 (0 marks): No creditworthy response.
Guidance: Do not accept 'faster' without a reason. Accept recommendation of linear search or bubble sort only if justified with reference to the context (maximum Band 2 if the justification is weak or ignores the sorted-data condition).
Question 15 · Code-writing task
6 marks
A greenhouse sensor records the temperature once an hour. The readings for one day are stored in a one-dimensional array called readings, which holds 24 real numbers.
Write a function, longestWarmSpell, that: - takes the array readings and a real number limit as parameters - finds the longest run of consecutive readings that are all strictly greater than limit - returns the length of that run (0 if no reading is greater than limit).
You may write your answer in pseudocode or a high-level programming language. [6]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Keep a counter of the current run of warm readings and a second variable holding the longest run seen so far. Step through every element. If the reading is above the limit, add 1 to the current run and update the best if the current run is now longer. Otherwise the run is broken, so reset the current counter to 0. After the loop, return the best value. For example, with limit 20 and readings 18, 21, 22, 19, 23, 24, 25, 17 the runs are 2 and 3, so 3 is returned.
Marking scheme
1 mark per bullet up to a maximum of 6 marks: - Function header with two parameters (readings, limit) // returns a value (1) - Initialising a current-run counter and a best-run variable to 0 (1) - Loop that visits every element of the array (1) - Comparison reading > limit (strictly greater) and current-run counter incremented (1) - Else branch / otherwise resets the current-run counter to 0 (1) - Updates best when current > best ... and returns best after the loop (1)
Guidance: Accept any loop construct that visits all 24 elements, 0- or 1-based indexing if used consistently. Accept Math.max / max() style update of best. Do not accept >= instead of >. Do not award the final mark if best is returned inside the loop. Example solution is only one possible answer.
Question 16 · Code-writing task
6 marks
A theatre stores the seat numbers of sold tickets in a one-dimensional array called sold. The seat numbers are integers held in ascending order with no duplicates.
Write a function, isSold, that uses a binary search to decide whether a given seat number has been sold. The function should: - take the array sold and an integer seat as parameters - return the index at which seat is found, or -1 if it is not in the array.
You may write your answer in pseudocode or a high-level programming language. [6]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Maintain low and high pointers marking the part of the array still to be searched. While the range is not empty, find the middle index using integer division. If the middle item equals the seat, return its index. If it is smaller than the seat, the seat can only be in the upper half, so move low above mid. Otherwise move high below mid. If the loop ends because low has passed high, the seat is not present, so return -1.
Marking scheme
1 mark per bullet up to a maximum of 6 marks: - Function header with two parameters and a return of a value (1) - Low initialised to 0 and high to length - 1 (1) - Loop that continues while low <= high (1) - Midpoint calculated using integer division of (low + high) by 2 (1) - If sold[mid] equals seat, return mid (1) - Correctly adjusts low = mid + 1 or high = mid - 1 depending on comparison ... and returns -1 after the loop (1)
Guidance: Accept a recursive solution if it scores the same points. Accept 1-based indexing if used consistently. Accept a found flag instead of returning inside the loop. Do not accept a linear search (maximum 2 marks). Do not accept low = mid or high = mid, as this can loop forever. Example solution is only one possible answer.
Question 17 · Code-writing task
6 marks
A print server holds waiting jobs in a circular queue. The queue is stored in a global array called jobs with 5 elements (indexes 0 to 4). Two global integer variables are used: - front, the index of the job at the front of the queue - count, the number of jobs currently in the queue.
Write a function, enqueue, that: - takes a job name (a string) as a parameter - does not change the queue and returns False if the queue is already full - otherwise adds the job at the rear of the queue, wrapping round to the start of the array where necessary, and returns True.
You may write your answer in pseudocode or a high-level programming language. [6]
Show answer & marking schemeHide answer & marking scheme
Worked solution
The queue is full when count equals the array size, 5, so return False straight away. Otherwise the next free position is the front index plus the number of items, wrapped using MOD 5 so that it returns to index 0 after index 4. Store the name at that position, add 1 to count and return True. For example, if front is 3 and count is 3, the rear is (3 + 3) MOD 5 = 1.
Marking scheme
1 mark per bullet up to a maximum of 6 marks: - Function header with one parameter and values returned (1) - Checks whether the queue is full (count == 5 // count == jobs.length) (1) - Returns False when full without changing the array or count (1) - Calculates rear position as (front + count) with wrap-around using MOD 5 (1) - Stores the job name in jobs at the calculated position (1) - Increments count ... and returns True (1)
Guidance: Accept a maintained rear pointer if it is correctly wrapped, and FT from a correct rear calculation. Accept front-based equivalents such as an IF that resets the index to 0 after 4. Do not accept (front + count) without wrapping for the fourth mark. Do not award the final mark if count is not incremented. Example solution is only one possible answer.
Question 18 · Trace table
4 marks
A technician, Imran, writes a subroutine to analyse a number written in base 8.
1 x = 2517 2 count = 0 3 while x > 0 4 d = x MOD 8 5 if d > 3 then 6 count = count + 1 7 endif 8 x = x DIV 8 9 endwhile 10 print(count)
Complete a trace table with columns x, d and count to show the execution of this algorithm. State the value that is output. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Start: x=2517, count=0. Iteration 1: d = 2517 MOD 8 = 5; 5 > 3 so count = 1; x = 2517 DIV 8 = 314. Iteration 2: d = 314 MOD 8 = 2; count stays 1; x = 39. Iteration 3: d = 39 MOD 8 = 7; count = 2; x = 4. Iteration 4: d = 4 MOD 8 = 4; count = 3; x = 0. Loop ends as x is not > 0. Output 3.
1 mark: correct x column values 2517, 314, 39, 4, 0. 1 mark: correct d column values 5, 2, 7, 4 (in order). 1 mark: correct count column values 0, 1, 1, 2, 3. 1 mark: output of 3 stated. Guidance: Accept values shown in a different but clear table layout. Do not accept d shown for a fifth iteration. FT the output from the candidate's final count if the trace is followed consistently. Correct answer only for the output mark if no trace is shown is still awarded.
Question 19 · Sort passes
4 marks
A bubble sort is used to arrange the following array into ascending order. Each pass starts at index 0, compares adjacent items and swaps them if they are in the wrong order. Index 0 is on the left.
[7, 3, 9, 2, 5, 4]
(a) Write down the contents of the array after the first pass. [1] (b) Write down the contents of the array after the second pass. [1] (c) State the number of swaps made during the first pass. [1] (d) The algorithm uses a flag to record whether any swaps were made in a pass and stops when a pass makes no swaps. State the total number of passes made, including the final pass, for this data. [1]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Pass 1: 7,3 swap -> 3,7,9,2,5,4; 7,9 no swap; 9,2 swap; 9,5 swap; 9,4 swap -> [3,7,2,5,4,9]. 4 swaps. Pass 2: 3,7 no; 7,2 swap; 7,5 swap; 7,4 swap -> [3,2,5,4,7,9]. Pass 3: 3,2 swap; 3,5 no; 5,4 swap -> [2,3,4,5,7,9]. The array is now sorted but swaps were made. Pass 4: no swaps, so the algorithm stops. Total 4 passes.
Marking scheme
(a) 1 mark: [3, 7, 2, 5, 4, 9]. (b) 1 mark: [3, 2, 5, 4, 7, 9]. (c) 1 mark: 4. (d) 1 mark: 4. Guidance: Correct answer only for each part. Accept the array written without brackets or commas. FT in (b) from an incorrect (a) if the pass is applied correctly.
Question 20 · Sort passes
4 marks
An insertion sort is used to arrange the following array into ascending order. The item at index 0 is treated as the sorted part to begin with. Each pass then takes the next item and inserts it into the correct position in the sorted part on its left.
[6, 2, 8, 1, 5]
Write down the contents of the whole array after each of the four passes. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
Pass 1: insert 2 before 6 -> [2, 6, 8, 1, 5]. Pass 2: 8 is larger than 6, stays in place -> [2, 6, 8, 1, 5]. Pass 3: insert 1 at the front, shifting 2, 6, 8 right -> [1, 2, 6, 8, 5]. Pass 4: insert 5 between 2 and 6 -> [1, 2, 5, 6, 8].
Marking scheme
1 mark per correct array after each pass, maximum 4. Pass 1 [2,6,8,1,5]; Pass 2 [2,6,8,1,5]; Pass 3 [1,2,6,8,5]; Pass 4 [1,2,5,6,8]. Guidance: Accept a repeated array for pass 2. Do not accept only the sorted part shown unless the remaining items are also given. FT allowed if a previous pass is wrong but the pass is applied correctly to the candidate's earlier array.
Question 21 · Code completion
4 marks
A library stores book codes in an array called codes, sorted in ascending order. The function below uses a binary search to return the index of target, or -1 if it is not found. Four parts of the code have been replaced by the letters A to D.
1 function findCode(codes, target) 2 low = 0 3 high = codes.length - 1 4 while A 5 mid = (low + high) DIV 2 6 if codes[mid] == target then 7 return mid 8 elseif codes[mid] < target then 9 low = B 10 else 11 high = C 12 endif 13 endwhile 14 return D 15 endfunction
State the code that should replace each of A, B, C and D. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
A: the loop continues while the search range is non-empty, so low <= high. B: if codes[mid] is smaller than the target, the target must lie to the right, so low = mid + 1. C: otherwise the target lies to the left, so high = mid - 1. D: if the loop ends without finding the target, return -1.
Marking scheme
1 mark: A low <= high. 1 mark: B mid + 1. 1 mark: C mid - 1. 1 mark: D -1. Guidance: Accept equivalent conditions for A such as NOT(low > high). Do not accept low < high for A. Do not accept B as mid or C as mid, as these can cause an infinite loop.
Wondering how well you actually know this?
thinka is an AI practice app for GCSE & A-Level students: unlimited questions, instant auto-marking, and detailed step-by-step solutions. 100,000+ students use it to confirm they actually know it, not just think they do.