←

Paper 2: Algorithms and programming

1(a)3 marks
Explain what abstraction is and how it is used in a map of a train network.
1(b)3 marks
Explain how decomposition could help develop a school timetable program.
1(c)3 marks
Explain what is meant by caching and one disadvantage of it.
1(d)3 marks
Explain one benefit and one drawback of designing a game so that tasks run concurrently.
2(a)4 marks
procedure change(byVal a, byRef b)    a = a * 2    b = b + aendprocedure x = 3y = 4change(x, y)print(x)print(y)
State the outputs and explain the difference between passing by value and by reference.
2(b)6 marks
function power(base, exp)    if exp == 0 then        return 1    else        return base * power(base, exp - 1)    endifendfunction
Rewrite power as an iterative function and compare the two versions.
2(c)8 marks
Write a function validPassword(pw) that returns true only if the password is at least 10 characters long, contains at least one digit and at least one upper-case letter, and contains no spaces.
2(d)9 marks
Write a class Account with private attributes accountNumber and balance, a constructor, a getBalance method and a withdraw(amount) method that only allows withdrawals that do not make the balance negative. Then write a subclass SavingsAccount that adds an interestRate attribute and an addInterest method.
2(e)4 marks
Describe four features of an IDE that help programmers to find and fix errors.
2(f)3 marks
Explain the difference between local and global variables and why local variables are preferred.
3(a)4 marks
Show the steps of a binary search for 40 in the list [3, 9, 14, 21, 27, 33, 40, 48, 52].
3(b)4 marks
Show each pass of an insertion sort on [5, 2, 8, 1, 9].
3(c)5 marks
Describe how merge sort works and state its time complexity.
3(d)4 marks
Explain the meaning of O(1), O(n), O(n²) and O(2ⁿ), giving an example of each.
3(e)4 marks
Explain how A* search differs from Dijkstra's algorithm.
3(f)6 marks
Write pseudocode for push(item) and pop() for a stack stored in an array of size 10 with a pointer top (initially −1), including checks for overflow and underflow.
3(g)5 marks
Describe how a new node is inserted into an ordered linked list.
3(h)4 marks
The values 50, 30, 70, 20, 40, 60, 80 are inserted into a binary search tree in that order. Describe where 65 would be inserted and why.
3(i)4 marks
A graph has edges A–B, A–C, B–D, C–D, C–E, D–F. Give the order of a breadth-first traversal from A (visit neighbours alphabetically) and name the data structure used.
4(a)5 marks
Section B — A cinema chain wants a seat-booking system. Each screen has rows A–M with 20 seats per row. Customers choose a film, a time and the number of seats, and the system suggests seats together. Identify the inputs, outputs and stored data, and one abstraction the designers could make.
4(b)4 marks
Describe a suitable data structure to store seat availability for one screening.
4(c)10 marks
Write a function findSeats(row, n) that returns the index of the first seat of the first block of n adjacent free seats in the given row, or −1 if there is none.
4(d)6 marks
Describe a test plan for findSeats, including normal, boundary and erroneous data.
4(e)8 marks
Tickets cost £12 for adults and £8 for children; screenings before 5pm are 25% cheaper; a group of 6 or more people gets £1 off each ticket. Write an algorithm to calculate the total price for a booking.
4(f)9 marks
The chain wants to allocate seats so that groups are kept together and as few single seats as possible are left empty. Discuss how backtracking or heuristic methods could be used to solve this problem.
4(g)12 marks
Evaluate the use of an object-oriented approach for developing the cinema booking system.

Finished?

Answer every question to finish (26 left), or finish when the time’s up.

Score 0 / 140 · 0 of 26 marked

This paper is written by Plasmo in the style of the OCR A-Level Computer Science exam. It is not a past paper and is not produced or endorsed by the exam board.

OCR A-Level Computer Science Mock Exam: Paper 2: Algorithms and programming | Plasmo