BREAKING
Student's code works, nobody knows why, including student★Local teen writes pseudocode, accidentally invents a language★Binary joke told in class, exactly 10 students laugh★
  1. Home
  2. A Level
  3. Computer Science
  4. OCR
  5. Standard sorting algorithms

OCR A Level Computer Science

Topic questions Algorithms Standard sorting algorithms

Standard sorting algorithms

10 questions · 188 marks · about 3.5 hours

Standard sorting algorithms questions

OCR H446 Standard sorting algorithms 10 questions

Algorithms and programming June 2025, Question 1 22 marks

Data in a computer program needs to be sorted.

(a)
(a)(i)

Describe the steps a bubble sort will take to sort items into ascending order.

[5]
Reveal mark scheme Mark scheme for question 1(a)(i)
(a)(ii)

Darcie and Felix have both written a program that will perform a bubble sort to put these numbers into ascending order.

Figure for question 1

Darcie’s version will complete six passes. However, Felix’s version will only need to complete two passes.

Explain how Felix may have made his version more efficient than Darcie’s version.

[2]
Reveal mark scheme Mark scheme for question 1(a)(ii)
(b)

A second type of sorting algorithm is an insertion sort.

Describe how an insertion sort can be used to put the following data into ascending order.

Figure for question 1
[5]
Reveal mark scheme Mark scheme for question 1(b)
(c)

A third type of sorting algorithm is a quick sort.

The following quick sort algorithm is made up of two functions called partition() and quickSort(). The algorithm will sort an integer array into ascending numerical order.

Figure for question 1
(c)(i)

Identify which of the two functions is recursive and give all of the line numbers where recursive calls are made.

Recursive function name........

Recursive call line numbers........

[2]
Reveal mark scheme Mark scheme for question 1(c)(i)
(c)(ii)

Identify the type of iteration used in the function partition().

[1]
Reveal mark scheme Mark scheme for question 1(c)(ii)
(c)(iii)

Describe the role of the function partition() in the quick sort algorithm.

[3]
Reveal mark scheme Mark scheme for question 1(c)(iii)
(c)(iv)

The algorithm needs to be changed to sort the integer array into descending numerical order.

Identify the line number that needs to be changed and write the amended line of code.

Amended line of code........

[2]
Reveal mark scheme Mark scheme for question 1(c)(iv)
(c)(v)

The quick sort is an example of a divide-and-conquer algorithm.

Describe what divide-and-conquer means.

[2]
Reveal mark scheme Mark scheme for question 1(c)(v)

Algorithms and programming June 2024, Question 6 15 marks

The following strings are stored in an array.

Figure for question 6
(a)

Explain how a linear search would search the array for the index that stores "clouds".

[3]
Reveal mark scheme Mark scheme for question 6(a)
(b)

State why a binary search cannot be used in this example.

[1]
Reveal mark scheme Mark scheme for question 6(b)
(c)

Show how an insertion sort will sort the given data into ascending alphabetical order.

Figure for question 6
[5]
Reveal mark scheme Mark scheme for question 6(c)
(d)
(d)(i)

A sorting algorithm has a best time complexity of O(n).

Describe what is meant by the best time complexity O(n) for a sorting algorithm.

[2]
Reveal mark scheme Mark scheme for question 6(d)(i)
(d)(ii)

Another sorting algorithm has a worst space complexity of O(log(n)).

Describe what is meant by the worst space complexity O(log(n)) for a sorting algorithm.

[2]
Reveal mark scheme Mark scheme for question 6(d)(ii)
(d)(iii)

Identify the time complexity that means the time will not change even when the number of items increases.

[1]
Reveal mark scheme Mark scheme for question 6(d)(iii)
(d)(iv)

Identify the space complexity that means the amount of memory (space) used will double each time a new item is included.

[1]
Reveal mark scheme Mark scheme for question 6(d)(iv)

Algorithms and programming June 2023, Question 7 26 marks

(a)

7* (a) A program designer needs to decide on an algorithm to use from a choice of three. The table shows the worst-case Big O complexities for each algorithm.

AlgorithmTime ComplexitySpace Complexity
1LinearExponential
2ExponentialConstant
3LogarithmicLogarithmic

The program will be used to analyse data that can range from 2 items to 2 billion items.

Compare the use of all three algorithms and suggest which the programmer should use.

You should include the following in your answer:

• the meaning of constant, logarithmic, linear and exponential complexity

• how well each algorithm scales as the amount of data increases

• which algorithm is the most suitable for the given task.

[9]
Reveal mark scheme Mark scheme for question 7(a)
(b)

The program designer is investigating the use of concurrent processing.

(b)(i)

Describe what is meant by the term ‘concurrent processing’.

[2]
Reveal mark scheme Mark scheme for question 7(b)(i)
(b)(ii)

Give two benefits of using concurrent processing.

[2]
Reveal mark scheme Mark scheme for question 7(b)(ii)
(c)

The programmer needs to use a merge sort in one part of the problem to sort items in ascending order.

(c)(i)

Describe how a merge sort works.

[5]
Reveal mark scheme Mark scheme for question 7(c)(i)
(c)(ii)

Give one benefit and one drawback of the programmer using a merge sort instead of a bubble sort.

[2]
Reveal mark scheme Mark scheme for question 7(c)(ii)
(d)

The programmer uses an Integrated Development Environment (IDE).

Complete the table by identifying and describing three IDE features that can help the programmer to develop, or debug a program.

Figure for question 7
[6]
Reveal mark scheme Mark scheme for question 7(d)

Algorithms and programming June 2022, Question 3 22 marks

Also involves Arrays

A bubble sort will sort an array of 50 integer values called numberArray.

(a)

State why the integer values are stored in an array instead of separate variables.

[1]
Reveal mark scheme Mark scheme for question 3(a)
(b)

This bubble sort algorithm is written to sort numberArray into ascending numerical order.

Complete this bubble sort algorithm.

Figure for question 3
[5]
Reveal mark scheme Mark scheme for question 3(b)
(c)

One section of numberArray is shown here.

Figure for question 3

A second sorting algorithm that could be used to sort this data is a merge sort.

Show how a merge sort will sort this section of the array numberArray into ascending numerical order.

[4]
Reveal mark scheme Mark scheme for question 3(c)
(d)

* Another sorting algorithm is insertion sort.

The number of values stored in the array numberArray has been reduced to 10.

Compare the use of bubble, merge and insertion sorts on the array numberArray.

You should include the following in your answer:

• how each algorithm works

• the Big O complexities for each algorithm

• the suitability of each algorithm for sorting the 10 values.

[12]
Reveal mark scheme Mark scheme for question 3(d)

Algorithms and programming November 2021, Question 3 7 marks

(a)

A one dimensional array holds data that needs to be sorted.

Describe how a quicksort would sort data into ascending order.

[5]
Reveal mark scheme Mark scheme for question 3(a)
(b)

Explain why a quicksort is known as a divide and conquer algorithm.

[2]
Reveal mark scheme Mark scheme for question 3(b)

Algorithms and programming November 2020, Question 4 20 marks

The following pseudocode procedure performs an insertion sort on the array parameter.

Figure for question 4
(a)

Explain why dataArray is passed by reference and not by value.

[2]
Reveal mark scheme Mark scheme for question 4(a)
(b)

State whether the procedure insertionSort sorts the data into ascending or descending order and explain your choice.

[3]
Reveal mark scheme Mark scheme for question 4(b)
(c)

* Two other sorting algorithms are merge sort and quick sort.

Compare the use of merge sort, quick sort and insertion sort on an array with a small number of elements, and on an array with a very large number of elements.

You should make reference to the time complexities of each algorithm using the Big O notation in your answer.

[9]
Reveal mark scheme Mark scheme for question 4(c)
(d)

A fourth sorting algorithm is a bubble sort.

Describe how a bubble sort will sort an array of 10 elements.

[6]
Reveal mark scheme Mark scheme for question 4(d)

Algorithms and programming June 2019, Question 1 17 marks

Also involves Stacks and queues

The temperatures of an ocean are input into a computer system. They are recorded, and will be accessed, in the order in which they arrive. The data for one week is shown:

5, 5.5, 5, 6, 7, 6.5, 6

(a)

The data is to be stored in a data structure. The programmer stores the data in a queue.

Explain why a queue is used instead of a stack.

[2]
Reveal mark scheme Mark scheme for question 1(a)
(b)

The data is processed. After processing, the value for the first day is stored as 0. The value for each following day is stored as an increase, or decrease, from the first day.

For example: if the first day was 7, the second was 6 and the third was 9, after processing it would be stored as 0, –1, 2.

(b)(i)

The queue uses dequeue() to return the first element of the queue.

dequeue() is a function.

Explain why dequeue() is a function, not a procedure.

[1]
Reveal mark scheme Mark scheme for question 1(b)(i)
(b)(ii)
Figure for question 1
[3]
Reveal mark scheme Mark scheme for question 1(b)(ii)
(b)(iii)

The contents of processedData are shown.

Figure for question 1

The data needs to be sorted into ascending order.

Explain how a bubble sort algorithm sorts data. Use the current contents of processedData in your explanation.

[5]
Reveal mark scheme Mark scheme for question 1(b)(iii)
(b)(iv)
Figure for question 1 Figure for question 1 Figure for question 1
[6]
Reveal mark scheme Mark scheme for question 1(b)(iv)

Algorithms and programming June 2019, Question 5 8 marks

A 1-dimensional array stores the following data:

Index012345
Data21864123
(a)

The array needs sorting into descending order.

Describe how a merge sort would sort the given array into descending order.

[6]
Reveal mark scheme Mark scheme for question 5(a)
(b)

An insertion sort can be used to sort the array instead of a merge sort.

Explain why an insertion sort might use less memory than a merge sort.

[2]
Reveal mark scheme Mark scheme for question 5(b)

Algorithms and programming June 2018, Question 5 29 marks

Also involves String manipulation

A computer program stores data input on a stack named dataItems. The stack has two sub-programs to add and remove data items from the stack. The stack is implemented as a 1D array, dataArray.

Figure for question 5

The current contents of dataItems are shown:

Figure for question 5
(a)
Figure for question 5
[4]
Reveal mark scheme Mark scheme for question 5(a)
(b)

The main program asks a user to push or pop an item from the stack. If the user chooses ‘push’, the data item is added to the stack. If the user chooses “pop”, the next item is removed from the stack, multiplied by 3 and output.

The main program is shown:

Figure for question 5
(b)(i)

Before the sub-programs, push() and pop(), can add or remove items from the stack, a selection statement is used to decide if each action is possible.

Describe the decision that needs to be made in each sub-program and how this impacts the next process.

Question 5, shown as an image
Question 5, shown as an image
[4]
Reveal mark scheme Mark scheme for question 5(b)(i)
(b)(ii)

The algorithm does not work when the user enters "PUSH" or "Push". The algorithm needs to be changed in order to accept these inputs.

Identify the line number to be changed and state the change that should be made.

Question 5, shown as an image
[2]
Reveal mark scheme Mark scheme for question 5(b)(ii)
(c)

The stack is implemented as a 1D array, dataArray.

Describe how a 1D array can be set up and used to push and pop items as a stack.

Figure for question 5

maths symbol

[3]
Reveal mark scheme Mark scheme for question 5(c)
(d)

As an array, the data in dataArray is sorted and then searched for a specific value.

(d)(i)

The data in dataArray is sorted into ascending order using an insertion sort.

The current contents of dataArray are shown:

Figure for question 5

Show the steps of an insertion sort on the current contents of the array dataArray.

Figure for question 5

maths symbol

[5]
Reveal mark scheme Mark scheme for question 5(d)(i)
(d)(ii)

The array dataArray can now be searched using a binary search.

Describe the stages of a binary search on an array of size n.

Figure for question 5

maths symbol

[7]
Reveal mark scheme Mark scheme for question 5(d)(ii)
(d)(iii)

The array has 50 items.

The function, searchItem(), performs a linear search for a data item.

Figure for question 5

Rewrite the function using a while loop.

Figure for question 5

maths symbol

[4]
Reveal mark scheme Mark scheme for question 5(d)(iii)

Algorithms and programming June 2017, Question 1 22 marks

A programmer needs to sort an array of numeric data using an insertion sort.

(a)(i)

The following, incomplete, algorithm performs an insertion sort.

Complete the algorithm.

Figure for question 1
[3]
Reveal mark scheme Mark scheme for question 1(a)(i)
(a)(ii)

Show how an insertion sort would sort the following data:

Figure for question 1
[6]
Reveal mark scheme Mark scheme for question 1(a)(ii)
(b)(i)

Using Big-O notation state the best case complexity of insertion sort.

[1]
Reveal mark scheme Mark scheme for question 1(b)(i)
(b)(ii)

Explain what your answer to part (b)(i) means.

[3]
Reveal mark scheme Mark scheme for question 1(b)(ii)
(c)

(c*) The number of data items in the array is continually increasing.

Insertion sort has a worst case time complexity of O(n2) and space complexity of O(1).

An alternative sorting algorithm that could be used is bubble sort which also has a worst case time complexity of O(n2) and space complexity of O(1).

Briefly outline how the bubble sort algorithm works. Discuss the relationship between the complexities and the two sorting algorithms and justify which of the two algorithms is best

suited to sorting the array.

[9]
Reveal mark scheme Mark scheme for question 1(c)

Report a problem with a question on this page
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Memes

Certified Computer Science memes. Peer-reviewed by nobody.

Laugh now. Cry in the exam hall later. Then come back and do a past paper.

Write a proper algorithm
Write ‘sort it’ and leave
Me on the 6-mark pseudocode question
Debugging with print statements
Using a trace table
Knowing the difference between = and ==
Explaining recursion by explaining recursion
Code enlightenment, ranked

Mum 💖

can you fix the wifi since you do computers 🥰

that's not what computer science is

so that's a no then

📱 Screen time this week · Discord8h 2m

Turned it off and on again

Computer Science starter pack

Laptop with 47 tabs openPython error on line 1Counting binary on fingersThis website
Compiled with zero errors