Oxford AQA International A-level · Computer Science (9645)

Following and writing algorithms: Practice Questions

5 multiple-choice questions marked as you go, and 5 written questions with worked solutions. All on Following and writing algorithms.

10 questions22 marksFree, no account
Question 1
1 mark

A linear search algorithm is used to find the value 25 in the following list: [10, 5, 25, 40, 15].
Assuming the algorithm stops as soon as the item is found, how many comparisons are made?

Question 2
1 mark

Which of the following statements accurately compares the worst-case time efficiency of Binary Search and Linear Search on a very large, sorted list containing \(n\) elements?

Question 3
1 mark

Hand-trace the following algorithm and determine the final value of B:

A = 6
B = 1
REPEAT
    A = A - 2
    B = B * 3
UNTIL B > A

Question 4
1 mark

What is the defining characteristic of an algorithm according to the standard definition in computer science?

Question 5
1 mark

Consider the list [8, 3, 6, 1]. After the first complete pass of the bubble sort algorithm (starting from the left and comparing adjacent elements), what is the state of the list?

Question 6
2 marks

What is the fundamental characteristic of an algorithm, as defined in computer science?

Write your answer out first, then check it against the worked solution.

Question 7
3 marks

Explain the primary purpose of hand-tracing an algorithm using a set of test data.

Write your answer out first, then check it against the worked solution.

Question 8
5 marks

Explain the importance of using erroneous test data when hand-tracing an algorithm intended for a production environment.

Write your answer out first, then check it against the worked solution.

Question 9
3 marks

Consider the following algorithm expressed in pseudocode:

START
X = 15
Y = 7
Z = 0
IF X > Y THEN
    Z = X MOD Y
    X = X DIV Y
ELSE
    Z = Y - X
    X = Y * 2
END IF
Y = Y + Z
OUTPUT X
OUTPUT Y
OUTPUT Z
END

Trace the execution of this algorithm, assuming standard integer arithmetic (DIV is integer division and MOD is the remainder), and state the final output values of X, Y, and Z.

Write your answer out first, then check it against the worked solution.

Question 10
4 marks

The following pseudocode processes an array Items of integers. Assume Items = [10, 4, 1, 9, 6] and the array indices run from 1 to 5 ( =5).

FUNCTION ProcessList(Items, n)
1. Total = 0
2. FOR I = 1 TO n DO
3.     Current = Items[I]
4.     IF Current < 5 AND Current MOD 2 == 0 THEN
5.         Total = Total + 1
6.     ELSE IF Current >= 10 OR Current MOD 3 == 0 THEN
7.         Total = Total + 2
8.     ELSE
9.         Total = Total + 0
10.     END IF
11. END FOR
12. RETURN Total

Hand-trace the execution of ProcessList(Items, 5) and state the final value returned by the function.

Write your answer out first, then check it against the worked solution.

* The content provided by thinka is generated by AI and may not always be accurate or up-to-date. Please use it as a supplementary resource and verify with official materials.

You've seen the model answer. Now get yours marked.

This page can show you how a good answer looks. It cannot tell you what your answer was missing. thinka marks your written work against the real mark scheme in about 15 seconds.

Want more questions like these? Get a fresh set on this topic, marked as you go.

Practise More