0% found this document useful (0 votes)
13 views

Merge Insertion Bubble Linear and Binary Search

The document discusses different sorting algorithms like merge sort, quick sort, insertion sort, and bubble sort. It provides pseudocode to demonstrate how these algorithms work and compares their time complexities using Big O notation. Examples are given to explain how to apply these sorting algorithms to arrays with different number of elements.

Uploaded by

sammytest30
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Merge Insertion Bubble Linear and Binary Search

The document discusses different sorting algorithms like merge sort, quick sort, insertion sort, and bubble sort. It provides pseudocode to demonstrate how these algorithms work and compares their time complexities using Big O notation. Examples are given to explain how to apply these sorting algorithms to arrays with different number of elements.

Uploaded by

sammytest30
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

1(a) The following pseudocode procedure performs an insertion sort on the array parameter.

01 procedure insertionSort(dataArray:byRef)
02 for i = 1 to dataArray.Length - 1
03 temp = dataArray[i]
04 tempPos = i – 1
05 exit = false
06 while tempPos >= 0 and exit == false
07 if dataArray[tempPos] < temp then
08 dataArray[tempPos + 1] = dataArray[tempPos]
09 tempPos = tempPos - 1
10 else
11 exit = true
12 endif
13 endwhile
14 dataArray[tempPos + 1] = temp
15 next i
16 endprocedure

* Two 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.

© OCR 2023. You may photocopy this page. 1 of 73 Created in ExamBuilder


© OCR 2023. You may photocopy this page. 2 of 73 Created in ExamBuilder
[9]

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

[6]

© OCR 2023. You may photocopy this page. 3 of 73 Created in ExamBuilder


2(a) A 1-dimensional array stores the following data:

Index 0 1 2 3 4 5
Data 2 18 6 4 12 3

The array needs sorting into descending order.

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

[6]

© OCR 2023. You may photocopy this page. 4 of 73 Created in ExamBuilder


(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]

(i) Describe how a merge sort differs from a bubble sort.

[4]

(ii) Name two sorting algorithms, other than a bubble sort and merge sort.

[2]

4 A 1-dimensional array stores a set of numbered cards from 0 to 7. An example of this data is shown in Fig in 4.1

© OCR 2023. You may photocopy this page. 5 of 73 Created in ExamBuilder


* Two sorting algorithms the programmer could have used are a merge sort and bubble sort.

The worst case scenario for Merge is O(n log(n)) and for Bubble is O(n^2).

Compare the use of a merge sort and a bubble sort on this array, evaluating the performance of each sort,
making reference to the worse case Big O notation.

[9]

© OCR 2023. You may photocopy this page. 6 of 73 Created in ExamBuilder


5(a) Poppy would like to use a bubble sort to sort 250 000 numbers into order from lowest to highest.

Currently the first five numbers before they have been sorted are:

195 584 167 147 158 187 160 125 184 236

Currently the last five numbers before they have been sorted are:

1058 19 558 1915 20 215 15

State the name of one other sorting algorithm that Poppy could have used.

[1]

(b) * Discuss how a bubble sort works and how efficient it will be when sorting these 250 000 items into order from
lowest to highest.

© OCR 2023. You may photocopy this page. 7 of 73 Created in ExamBuilder


[9]

(c) State the number of comparisons that will need to be made in the first pass of the bubble sort.

[1]

© OCR 2023. You may photocopy this page. 8 of 73 Created in ExamBuilder


(d) Bubble sorts make use of two different loops when sorting items into order.

Describe the two loops used and their purpose.

[4]

6 A procedure is shown in the following pseudocode.

The arrays that are passed to the procedure store integer values.

length returns the total number of elements the array can hold.

01 procedure calculateOnce(data[]:byRef, nextData[]:byRef)


02 if data.length > nextData.length then
03 loopCount = nextData.length - 1
04 else
05 loopCount = Data.length - 1
06 endif
07 count = 0
08 while count <= loopCount
09 data[count] = data[count] + nextData[count]
10 count = count + 1
11 endwhile
12 endprocedure

The program needs a second procedure, sortData. It will be called taking the array data[] as a parameter by

© OCR 2023. You may photocopy this page. 9 of 73 Created in ExamBuilder


reference.

The procedure will then perform a bubble sort on the data in the array.

(i) Show each stage of a bubble sort on the following contents of data[]:

95 10 5 33 100 77 45

[4]

© OCR 2023. You may photocopy this page. 10 of 73 Created in ExamBuilder


(ii) Write, using pseudocode, the procedure sortData.

[8]

(iii) An alternative sorting method is the insertion sort.

© OCR 2023. You may photocopy this page. 11 of 73 Created in ExamBuilder


Show how an insertion sort will sort the data in the following array.

95 10 5 33 100 77 45

[4]

© OCR 2023. You may photocopy this page. 12 of 73 Created in ExamBuilder


7 A games company has developed a game called Kidz Arrowz. The players throw an arrow at a target board and
are awarded different points depending on which circle the arrow lands. Fig. 1 shows the board.

Fig. 1

A computer program is required to keep track of the scores for each competition. The user will enter the number
of players, and the name of each player, in that competition to a maximum of 10.

(i) The programmer has decided to use a bubble sort to sort the players’ scores in descending order of score.

Describe the disadvantages of using a bubble sort.

[2]

© OCR 2023. You may photocopy this page. 13 of 73 Created in ExamBuilder


(ii) Despite the disadvantages, the programmer has decided to use a bubble sort for the players’ scores.

Identify the characteristic of this problem that minimises the disadvantages of a bubble sort.

[1]

(iii) Write a procedure, sortScores, to perform a bubble sort on the global array scores to sort the players’
scores into descending numeric order.

© OCR 2023. You may photocopy this page. 14 of 73 Created in ExamBuilder


[6]

(iv) An alternative sorting method is the insertion sort.

A procedure, insertionSort, has been written to sort an array numbers. The procedure is incomplete.

Complete the procedure.

procedure insertionSort()
for count = 0 to numbers.length - 1
position = ........................................................
while position > 0 and numbers[position] < numbers[position-1]
temp = .......................................................
numbers[position-1] = ........................................
numbers[position] = temp
position = ...................................................
endwhile
next count
endprocedure
[4]

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

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).

© OCR 2023. You may photocopy this page. 15 of 73 Created in ExamBuilder


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]

© OCR 2023. You may photocopy this page. 16 of 73 Created in ExamBuilder


© OCR 2023. You may photocopy this page. 17 of 73 Created in ExamBuilder
9(a) The following pseudocode procedure performs an insertion sort on the array parameter.

01 procedure insertionSort(dataArray:byRef)
02 for i = 1 to dataArray.Length - 1
03 temp = dataArray[i]
04 tempPos = i – 1
05 exit = false
06 while tempPos >= 0 and exit == false
07 if dataArray[tempPos] < temp then
08 dataArray[tempPos + 1] = dataArray[tempPos]
09 tempPos = tempPos - 1
10 else
11 exit = true
12 endif
13 endwhile
14 dataArray[tempPos + 1] = temp
15 next i
16 endprocedure

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

[2]

© OCR 2023. You may photocopy this page. 18 of 73 Created in ExamBuilder


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

[3]

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

Sub-program Description
push() The parameter is added to the top of the stack

pop() The parameter is added to the top of the stack

The current contents of dataItems are shown:

6
15
100
23

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

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

The current contents of dataArray are shown:

100 22 5 36 999 12

© OCR 2023. You may photocopy this page. 19 of 73 Created in ExamBuilder


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

[5]

(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.

© OCR 2023. You may photocopy this page. 20 of 73 Created in ExamBuilder


[7]

(iii) The array has 50 items.

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

function searchItem(dataItem)
for count = 0 to 49
if dataArray[count] == dataItem then
return(count)
endif
next count
return(-1)

© OCR 2023. You may photocopy this page. 21 of 73 Created in ExamBuilder


endfunction

Rewrite the function using a while loop.

[4]

© OCR 2023. You may photocopy this page. 22 of 73 Created in ExamBuilder


11(a) A programmer needs to sort an array of numeric data using an insertion sort.

(i) The following, incomplete, algorithm performs an insertion sort.

Complete the algorithm.

[3]

(ii) Show how an insertion sort would sort the following data:

© OCR 2023. You may photocopy this page. 23 of 73 Created in ExamBuilder


6 1 15 12 5 6 9

[6]

© OCR 2023. You may photocopy this page. 24 of 73 Created in ExamBuilder


(b)

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

[1]

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

[3]

© OCR 2023. You may photocopy this page. 25 of 73 Created in ExamBuilder


12

(i) Describe how an insertion sort is performed.

[3]

(ii) Demonstrate an insertion sort to place the following numbers into descending numerical order.

12 7 4 5 26

[4]

(iii) State one disadvantage of an insertion sort compared with a quick sort.

[1]

© OCR 2023. You may photocopy this page. 26 of 73 Created in ExamBuilder


13 A 1-dimensional array stores a set of numbered cards from 0 to 7. An example of this data is shown in Fig in 4.1

A programmer is writing a computer program to sort the cards into the correct order (0 to 7).

(i) Show how an insertion sort would sort the array in Fig 4.1 into the correct order. Draw the array after each
move.

[3]

(ii) Describe how a quick sort algorithm works with the data in Fig 4.2.

© OCR 2023. You may photocopy this page. 27 of 73 Created in ExamBuilder


[6]

14(a) Identify one situation where a linear search is more appropriate than a binary search.

[1]

© OCR 2023. You may photocopy this page. 28 of 73 Created in ExamBuilder


(b) The pseudocode function binarySearch() performs a binary search on the array dataArray that is passed
as a parameter. The function returns the array index of searchValue within the array, and -1 if it is not in the
array.

The pseudocode binary search algorithm is incomplete.

(i) Complete the algorithm by filling in the missing statements.

function binarySearch(dataArray:byref, upperbound, lowerbound, ………………………………)


while true
middle = lowerbound + ((upperbound – lowerbound) ………………………………)
if upperbound < lowerbound then
return ……………………………………………
else
if dataArray[middle] < searchValue then
lowerbound = ………………………………………………………………………………………………………………………
elseif dataArray[middle] > searchValue then
upperbound = ………………………………………………………………………………………………………………………
else
return ……………………………………………………………………………………………
endif
endif
endwhile
endfunction
[6]

(ii) The algorithm uses a while loop.

State a different type of loop that could be used instead of the while loop in the given algorithm.

[1]

© OCR 2023. You may photocopy this page. 29 of 73 Created in ExamBuilder


(c) The tables below show possible Big O complexities for the worst-case space, best-case space and average time
for search algorithms.

Tick the worst-case space complexity for a binary and linear search.

Binary Linear
search search
O(log(n))
O(1)
O(n)

Tick the best-case space complexity for a binary and linear search.

Binary Linear
search search
O(log(n))
O(1)
O(n)

Tick the average time complexity for a binary and linear search.

Binary Linear
search search
O(log(n))
O(1)
O(n)
[6]

© OCR 2023. You may photocopy this page. 30 of 73 Created in ExamBuilder


15 Oscar owns a taxi company. He would like a program to handle taxi bookings from customers.

Some of Oscar’s customers are rated as gold. Customers who are rated as gold are given priority when they
make a taxi booking. Some customers rated as gold are shown here.

Arshad Betty Dave Freddie Harry Jimmy Kanwal Lynn Siad Tommy Will

When a customer makes a booking, Oscar will make use of a binary search to check if they are gold rated.

Oscar would like to know if ‘Tommy’ is gold rated.

(i) State the three values that will be set as the midpoints and then checked against ‘Tommy’ on each iteration
of the binary search.

Show your working here.

Midpoint 1

Midpoint 2

Midpoint 3

[3]

(ii) Oscar has 75 000 customers stored in his program.

Describe the benefit to Oscar of using binary searches in his program.

Benefit

© OCR 2023. You may photocopy this page. 31 of 73 Created in ExamBuilder


[2]

(iii) State one other search algorithm that Oscar could have used.

[1]

(iv) State the pre-condition which has been met, which meant that Oscar did not need to use the search
algorithm you stated in the part above.

[1]

© OCR 2023. You may photocopy this page. 32 of 73 Created in ExamBuilder


16
A country’s national rail operator provides an app for customers to purchase tickets. An array is used to store
the names of the stations on the network. Customers must enter a departure station into the app.

The current contents of the array are shown:

Cavalry Bridge Walkway Museum Monument Council Theatre Cinema


House

A linear search is used to check if the entered departure station exists in the array.

(i) Identify one precondition that is needed before a binary search could be used with the station array.

[1]

(ii) A user enters the departure station ‘Bridge Heights’

Explain how a linear search would check if the departure station exists in the array.

[4]

© OCR 2023. You may photocopy this page. 33 of 73 Created in ExamBuilder


17 A programmer is developing an ordering system for a fast food restaurant. When a member of staff inputs an
order, it is added to a linked list for completion by the chefs.

The user needs to be able to search for, and find, a specific order number.

State an appropriate search algorithm that could be used, and justify your choice against an alternative Search
algorithm.

Appropriate Search Algorithm

Justification

[3]

© OCR 2023. You may photocopy this page. 34 of 73 Created in ExamBuilder


18 *A programmer is interested in using concurrent processing to perform a searching algorithm.

Explain how concurrent processing could be used in searching algorithms, and evaluate the benefits and trade-
offs from implementing concurrent processing in a searching algorithm.

[9]

© OCR 2023. You may photocopy this page. 35 of 73 Created in ExamBuilder


19(a) Describe the steps involved in a binary search to find the value 47 in the list below.

4, 7, 8, 21, 46, 47, 51

[4]

© OCR 2023. You may photocopy this page. 36 of 73 Created in ExamBuilder


(b) A programmer has been tasked with writing a function that uses a binary search to return a Boolean value. The
function should return true if the target integer is found in a list of integers. Using pseudocode, write an
algorithm for the function.

[8]

20 The list of positive even numbers up to and including 1000 is

2, 4, 6,… 500, 502,… 998, 1000

An attempt is to be made to find the number 607 in this list.

Use the values given to show the first three steps for:

© OCR 2023. You may photocopy this page. 37 of 73 Created in ExamBuilder


(i) a binary search

[3]

(ii) a serial search

[3]

(iii) Explain the difference between binary searching and serial searching.

[2]

(iv) State one advantage and one disadvantage of a binary search compared with a serial search.

[2]

© OCR 2023. You may photocopy this page. 38 of 73 Created in ExamBuilder


21(a) Linear search and binary search are two different algorithms which can be used for searching arrays.

When comparing linear and binary search it is possible to look at the best, worst and average number of items in
the array that need to be checked to find the item being searched for. Assume every item in the array is equally
likely to be searched for.

Complete the table below

Worst Case number of Average Case Best Case


searches
Binary Search Log2(n)-1
Linear Search n/2
[4]
(b) As the size of an array increases the average number of checks grows logarithmically. State what is meant by
logarithmic growth.

[1]
(c) Assuming an array is sorted give a situation when a linear search would perform better than a binary search.

[1]

END OF QUESTION PAPER

© OCR 2023. You may photocopy this page. 39 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

1 a Mark Band 3 – High level (7-9 marks) 9 AO1: Knowledge and Understanding
The candidate demonstrates a thorough AO1.1 Indicative content
knowledge and understanding of big O and (2) O(1)
sorting algorithms; the material is generally AO1.2
accurate and detailed. (2) Constant space, does not change
The candidate is able to apply their AO2.1
knowledge and understanding directly and (2) O(n)
consistently to the context provided. AO3.3
Evidence/examples will be explicitly (3) Linear
relevant to the explanation. Same as number of elements
The candidate is able to weigh up the use As number of elements increases so
of the sorting algorithms which results in a does the time/space
supported and realistic judgment as to
whether it is possible to use them in this O(n2)
context.
There is a well-developed line of reasoning polynominal
which is clear and logically structured. The As number of elements increases,
information presented is relevant and time/space increases by *n
substantiated.
O(n log(n))
Mark Band 2 – Mid level (4-6 marks)
The candidate demonstrates reasonable Linearithmic
knoledge and understanding of big O and
sorting algorithms; the material is generally
accurate but at times underdeveloped. AO2: Application
The candidate is able to apply their
knowledge and understanding directly to Space: Merge sort will require more
the context provided although one or two memory usage as the number of
opportunities are missed. elements increases. Insertion will not
Evidence/examples are for the most part require any more space than original.
implicitly relevant to the explanation. Quick will increase but not as much as
The candidate makes a reasonable merge.
attempt to come to a conclusion showing Best time: Insertion increases at the
some recognition of influencing factors that same rate as the number of elements.
would determine whether it is possible to Quick and merge increase at greater
use the sorting algorithms in this context. rate
There is a line of reasoning presented with Worst time: insertion and quick
some structure. The information presented increase significantly by n for each
is in the most part relevant and supported additional item. Merge sort increases
by some evidence less per element.
Log more appropriate for large number
Mark Band 1 – Low Level (1-3 marks) of elements
The candidate demonstrates a basic
knowledge of big O and sorting algorithms AO3: Evaluation
with limited understanding shown; the e.g.
material is basic and contains some
inaccuracies. The candidates makes a Small array – space is not important.
limited attempt to apply acquired Few number of elements. Look for
knowledge and understanding to the consistency.

© OCR 2023. You may photocopy this page. 40 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

context provided. Large array therefore memory


The candidate provides nothing more than important – could remove merge as
an unsupported assertion. inappropriate. Logarithmic more
The information is basic and comunicated efficient.
in an unstructured way. The information is
supported by limited evidence and the
relationship to the evidence may not be
clear.

0 marks
No attempt to answer the question or
response is not worthy of credit.

b 1 mark per bullet for description to max 6 6


AO1.1
Compare each pair of adjacent (2)
elements AO1.2
If they are not in the correct order then (4)
swap the elements
If they are in the correct order then do
no swap elements
When you read the end of the array
return to the start
Repeat n elements time
Set a flag to be false whenever a swap
is made
…repeat the loop if the flag is not false

Total 15

© OCR 2023. You may photocopy this page. 41 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

2 a 1 mark per bullet to max 6. 6 Allow max 5 if correct description but in


Max 4 if generic description given with no ascending order.
application AO1.2
Max 4 if a diagrammatic solution is given (3 Examiner’s Comments
with no description AO2.2
(3) Exemplar 3

• Splits the list in half repeatedly…


• … until it is in independent arrays /
elements e.g. 2, 18, 6, 4, 12, 3
• Compare the first two items (index 0
and 1) e.g. 2, 18
• … and combine to create a new array
in descending order i.e. 18, 2
• Repeat with indexes 2 and 3 (6, 4),
then 4 and 5 (12, 3)
• Compare the first element in the first
two new arrays
• …Choose the largest element, writing
this to the new array first
• …repeat until no elements left
• Combine the two remaining lists into A number of candidates simply presented
one list learnt definitions without application to the
e.g. e.g. given dataset, while other candidates
[2, 18, 6, 4, 12, 3] [2, 18, 6, 4, 12, 3] presented diagrammatic solutions to the
[2, 18, 6] [4, 12, 3] [2, 18, 6] [4, 12, 3] workings of the merge sort for the given
[2, 18] [6] [4, 12] [3] [2, 18] [6] [4, 12] [3] data, but did not explain what was
[2] [18] [6] [4] [12] [3] [2] [18] [6] [4] [12] [3] happening.
[18, 2] [6, 4] [12, 3] [18 2] [6] [12 4] [3]
[18, 6, 4, 2] [12, 3] [18 6 2] [12 4 3] Good responses such as the exemplar had
[18, 12, 6, 4, 3, 2] [18, 12, 6, 4, 3, 2] explanatory text alongside a clear diagram,
showing the steps that took place when the
algorithm was run.

b 1 mark per bullet 2


Examiner’s Comments
AO1.2
• Merge sort might create a new array (2) Many candidates recognised that merge
each time it splits and merges / often sort could generate an additional array
implemented recursively which places each time a list was split. Fewer could
additional data on the stack explain that insertion sort worked in-situ
• Insertion sort does not use any and has a space complexity O(1).
additional arrays//Insertion sort is an in-
place algorithm.

Total 8

© OCR 2023. You may photocopy this page. 42 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

3 i 1 mark per bullet to max 4 4 Allow points by demonstration/example

Merge sort splits the data


Merge sorts the split data as it is put
back together
Bubble moves through the data in a
linear way
Bubble moves through the data
repeatedly
Merge is more efficient with larger
volumes of data to sort
Merge may require more memory
space

ii 1 mark per example 2


e.g.

Insertion
Quick

Total 6

© OCR 2023. You may photocopy this page. 43 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

4 Mark Band 3 – High level 9 AO1: Knowledge and Understanding


(7–9 marks) Indicative content
The candidate demonstrates a thorough
knowledge and understanding of merge Merge sort uses sub-lists
and bubble sorts; the material is generally Bubble sort uses a temp element
accurate and detailed. Bubble sort moves through the list
The candidate is able to apply their repeatedly
knowledge and understanding directly and Merge sort divides the list into smaller
consistently to the context provided. lists
Evidence / examples will be explicitly Merge is a recursive algorithm
relevant to the explanation. Worst case is logarithmic, scales up
There is a well-developed line of reasoning well
which is clear and logically structured. The Worst case is exponential, does not
information presented is relevant and scale up well
substantiated.
AO2: Application
Mark Band 2 – Mid level
(4–6 marks) Small data set
The candidate demonstrates reasonable Few changes are needed
knoledge and understanding of merge and Demonstrates use of merge and / or
bubble sorts; the material is generally bubble on the array
accurate but at times underdeveloped. Calculations of average speed / best
The candidate is able to apply their speed / worse speed
knowledge and understanding directly to
the context provided although one or two AO3: Evaluation
opportunities are missed. Evidence / Candidates will need to evaluate the
examples are for the most part implicitly benefits and drawbacks of each sorting
relevant to the explanation. algorithm
The candidate provides a reasonable e.g.
discussion, the majority of which is
focused. Evaluative comments are, for the Merge is fast on large data sets
most part appropriate, although one or two Bubble is intuitive (easier to program)
opportunities for development are missed. Both are fast (or even) on smaller data
There is a line of reasoning presented with sets
some structure. The information presented Bubble's average speed is worse than
is in the most part relevant and supported merge
by some evidence. Bubble will be easier to write for such a
small data set
Mark Band 1 – Low Level Accept argument for either way as long
(1–3 marks) as justified
The candidate demonstrates a basic
knowledge of merge and bubble sorts with
limited understanding shown; the material
is basic and contains some inaccuracies.
The candidates makes a limited attempt to
apply acquired knowledge and
understanding to the context provided.
The candidate provides a limited
discussion which is narrow in focus.

© OCR 2023. You may photocopy this page. 44 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

Judgements if made are weak and


unsubstantiated.
The information is basic and comunicated
in an unstructured way. The information is
supported by limited evidence and the
relationship to the evidence may not be
clear.

0 marks
No attempt to answer the question or
response is not worthy of credit.

Total 9

© OCR 2023. You may photocopy this page. 45 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

5 a Insertion sort 1 Allow other sorting algorithms not listed in


A02.1 the specification (e.g. Merge Sort, Quick
(1) Sort etc)

© OCR 2023. You may photocopy this page. 46 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

b Mark Band 3 – High level (7-9 marks) 9 Knowledge and Understanding


The candidate demonstrates a thorough AO1.1
knowledge and understanding of bubble (2) All adjacent items are compared
sorts; the material is generally accurate AO1.2 against each other.
and detailed. The candidate is able to (2) The biggest number in the adjacent
apply their knowledge and understanding A02.1 pair is swapped over with the smallest
directly and consistently to the context (2) number. A temp variable is used to
provided. Evidence/examples will be A03.3 hold the data while it’s being moved.
explicitly relevant to the explanation. The (3) When a swap is made a flag is set.
candidate is able to weigh up the use of This is repeated for all adjacent values,
bubble sorts within the context which known as one pass.
results in a supported and realistic At the end of one pass, the largest item
judgment as to whether it is suitable to use should appear at the end of the list.
within the context.There is a well- If at the end of the list the flag has
developed line of reasoning which is clear been set the flag is unset and the
and logically structured. The information algorithm starts from the beginning of
presented is relevant and substantiated. the list again.
When the algorithm gets to the end of
Mark Band 2 – Mid level (4-6 marks) the list and the flag is unset the list is
The candidate demonstrates reasonable sorted.
knowledge and understanding of bubble
sorts; the material is generally accurate but Application
at times underdeveloped.The candidate is
able to apply their knowledge and As there are 250,000 items a bubble
understanding directly to the context sort would perform very slowly as a lot
provided although one or two opportunities of passes will need to be made in order
are missed. Evidence/examples are for the to sort the items.
most part implicitly relevant to the Bubble sorts are better suited to data
explanation. sets where the items are almost/partly
The candidate makes a reasonable sorted. However the smaller numbers
attempt to come to a conclusion showing are currently towards the end and the
some recognition of influencing factors that larger numbers are towards the start.
would determine whether it is possible to This will therefore increase the amount
use bubble sorts in this context. of comparisons / passes/swaps
There is a line of reasoning presented with required which will therefore slow the
some structure. The information presented performance of the sort down.
is in the most part relevant and supported
by some evidence Evaluation

Mark Band 1 – Low Level (1-3 marks) The algorithm is easy to implement as
The candidate demonstrates a basic the number of lines of code is less than
knowledge of bubble sorts with limited other standard sorting algorithms.
understanding shown; the material is basic Although a bubble sort will be able to
and contains some inaccuracies. The sort the items into order, it will take
candidates makes a limited attempt to longer than other sorting algorithms
apply acquired knowledge and due to the number of items and the
understanding to the context provided. The current order or items in the unsorted
candidate provides nothing more than an list.
unsupported assertion.The information is

© OCR 2023. You may photocopy this page. 47 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

basic and comunicated in an unstructured


way. The information is supported by
limited evidence and the relationship to the
evidence may not be clear.

0 marks
No attempt to answer the question or
response is not worthy of credit.

c 249,999 1
A02.2
(1)

d 1 mark per bullet up to a maximum of 4 4 Allow other valid interpretations


marks: A01.2 e.g. conditional while loop … used to
(4) compare against swap flag after each
The inner loop will compare all of the pass; counter controlled for loop … used to
adjacent items…. check adjacent items on each pass
….in a single pass
The outer loop will repeat the process
of checking adjacent items….
…until all passes are complete / the
items are sorted/no swaps have been
made in a pass

Total 15

© OCR 2023. You may photocopy this page. 48 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

6 i 1 mark per set of swaps 4 AO1.1 Pair swaps may be shown individually or at
(1) AO1.2 the end of each traversal (award mark
(1) AO2.1 point 1 and 2 if first traversal is shown on
10 95 5 33 100 77 45 1 (2) one line)
10 5 95 33 100 77 45
Examiner’s Comments
10 5 33 95 100 77 45
10 5 33 95 77 100 45 1 A high proportion of candidates knew the
basic principle of a Bubblesort and how it
10 5 33 95 77 45 100
operated, with most candidates obtaining
5 10 33 95 77 45 100 1 at least the first marking point. Some
5 10 33 77 95 45 100 candidates gave textual descriptions that
5 10 33 77 45 95 100 made it difficult to follow the logic of the
response. Those candidates that
5 10 33 45 77 95 100 1 presented each step in the algorithm,
clearly highlighting each swap that took
place, demonstrated the clearest
understanding.

Exemplar 1

Exemplar 1 illustrates a candidate


response that shows each of the swaps in
the Bubblesort clearly identified.

© OCR 2023. You may photocopy this page. 49 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

ii 1 mark per bullet max 8 8 AO1.1 Examiner’s Comments


(2) AO3.2
Procedure declaration (6) Most candidates wrote pseudocode, but a
…taking array as parameter by few candidates wrote in a vague structured
reference English or in a textual description that was
Outer loop, looping the number of not creditworthy. Bubble sort is one of the
times there are elements… few algorithms that candidates must be
Inner loop, looping through all able to program and to recall, so it was,
elements of the loop (or one less perhaps, surprising that many candidates
element each iteration) were not able to achieve more than 5
Comparing two elements marks. Common mistakes included loops
Swapping two elements if out of order that would, when executed, have resulted
…using an appropriate temp memory in array out bounds errors. The strongest
space or equivalent candidates wrote an efficient
Efficiency: stopping as soon as no implementation of a bubble sort that
swaps have been made stopped executing when no more swaps
had occurred during a pass.
e.g.
procedure
sortData(data[]:byRef)

swapped = true
while swapped == true
swapped = false

for innerCount = 0 to
data.length - 2
if data[innerCount] > data
[innerCount + 1] then
temp = data[innerCount]
data[innerCount] = data
[innerCount + 1]
data[innerCount+1] =
temp
swapped = true
end if
next innerCount

endwhile

endprocedure

© OCR 2023. You may photocopy this page. 50 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

iii 1 mark per row(s) as shown: 4 AO1.2 In the 3rd mark point the line may appear
(2) AO2.1 just once
(1) AO2.2
95 10 5 33 100 77 45 (1) Examiner’s Comments
10 95 5 33 100 77 45 1
Those candidates who understood the
5 10 95 33 100 77 45 1 principles behind insertion sort often clearly
5 10 33 95 100 77 45 1 delineated their responses into the 'sorted'
and the 'unsorted' parts of the array. This
5 10 33 95 100 77 45
made it easier to follow the steps that had
5 10 33 77 95 100 45 1 been applied. Some candidates wrote long-
5 10 33 45 77 95 100 winded textual descriptions of the
principles of the process without actually
showing how the principles applied to the
actual data, which meant that credit could
not be given.

Exemplar 2

Exemplar 2 illustrates a candidate


response that shows each of the steps of
the insertion sort in a clear diagrammatic
format.

Total 16

© OCR 2023. You may photocopy this page. 51 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

7 i 1 mark per bullet to max 2 2


AO1.2
Bubble sort is an inefficient algorithm… (1)
Meaning it will take more AO2.2
time/processing cycles to sort the list. (1)
Generally outperformed by Insertion Examiner’s Comments
sort/quick sort/ merge sort (accept any
other sensible sorting algorithm) Most candidates identified the inefficiency
The item to be sorted is at the end of of the bubble sort but fewer could expand
the list (and so can only move back upon this.
one place per pass) which is the worst
case scenario for bubble sort.

ii There are only a small number of data 1


items AO2.2 Examiner’s Comments
(1)
Most candidates correctly identified that
that the list to sort was small.

iii 1 mark per bullet to max 6 6


AO1.2
Procedure declaration (2)
Outer loop until no swaps made using AO2.2
flag (1)
Inner loop to iterate through the list… AO3.2
…allowance for largest value at end (in (3)
bounds) Examiner’s Comments
Comparing elements
Swapping elements Those candidates who had learnt the
standard sorting algorithms had little
e.g. difficulty producing good pseudocode for
procedure sortScores() the bubble sort. Unfortunately, many
do candidates had not learnt the code for the
sorted = true standard algorithms.
for j = 0 to 19
if scores[j].totalScore >
scores[j+1].totalScore then
temp = scores[j+1]
scores[j+1] = scores[j]
scores[j = temp
sorted = false endif
next j
until sorted = true
endprocedure

© OCR 2023. You may photocopy this page. 52 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

iv 1 mark for each completed space 4


AO2.2
procedure insertionSort() (3)
for count = 0 to AO3.2
numbers.length-1 (1)
position = count
while position > 0 and numb
ers[position]<numbers[position- Examiner’s Comments
1]
temp = numbers[position-1] Candidates who were confident in
numbers[position-1] = analysing code often answered
numbers[position] successfully and could calculate the
numbers[position] = temp correct way to index the numbers[ ] array.
position = position-1
endwhile
next count
endprocedure

Total 13

© OCR 2023. You may photocopy this page. 53 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

8 Mark Band 3 - High level 9 AO1: Knowledge and Understanding


(7–9 marks) AO1.1 Indicative content
The candidate demonstrates a thorough (2)
knowledge and understanding of how AO1.2
bubble sort works and Big O complexity; (2) Description of bubble sort:
the material is generally accurate and AO2.1 ◊Starting at the beginning of the list
detailed. (2) Items are swapped with their
The candidate is able to apply their AO3.3 neighbour if they are out of order.
knowledge and understanding directly and (3) ◊Each pair of neighbours is checked in
consistently to the context provided. order.
Evidence / examples will be explicitly ◊When a swap is made a flag is set.
relevant to the explanation. ◊If at the end of the list the flag has
There is a well-developed line of reasoning been set the flag is unset and the
which is clear and logically structured. algorithm starts from the beginning of
The information presented is relevant and the list again.
substantiated. ◊When the algorithm gets to the end
of the list and the flag is unset the list
Mark Band 2 - Mid level is sorted and the algorithm finishes.
(4–6 marks)
The candidate demonstrates reasonable O(n2) denotes as the data size
knowledge and understanding of of how increases the time the list takes to sort
bubble sort works and Big O complexity; increases in a quadratic manner.
the material is generally accurate but at O(1) denotes the space used is
times underdeveloped. constant
The candidate is able to apply their
knowledge and understanding directly to AO2: Application
the context provided although one or two
opportunities are missed.
Evidence / examples are for the most part As data set gets bigger, bubble sort's
implicitly relevant to the explanation. time gets larger at an increasing rate..
The candidate provides a reasonable Complexity doesn't denote the actual
discussion, the majority of which is time but the order with which the time /
focused. Evaluative comments are, for the space grows.
most part appropriate, although one or two O(1) space complexity means no
opportunities for development are missed. matter how big the data set becomes
There is a line of reasoning presented with the amount of space (extra to the data
some structure. The information presented itself) remains the same.
is in the most part relevant and supported O(n2) time complexity means as
by some evidence. n increases time increases by n2 /
if n doubles the time taken is squared.
Mark Band 1 - Low Level Bubble sort can be tweaked with
(1–3 marks) improvements (e.g. checking one less
The candidate demonstrates a basic item per iteration and alternating
knowledge of of how bubble sort works and sorting directions).
Big O complexity with limited These optimisations don't change the
understanding shown; the material is basic complexity. IT will run a little quicker on
and contains some inaccuracies. smaller sets but time taken increases
rapidly with data size.

© OCR 2023. You may photocopy this page. 54 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

The candidates make a limited attempt to When choosing an algorithm we may


apply acquired knowledge and also want to take into account the
understanding to the context provided. average and best case scenarios.
The candidate provides a limited (in this case they are also the same for
discussion which is narrow in focus. both algorithms.)
Judgements if made are weak and
unsubstantiated. AO3: Evaluation
The information is basic and comunicated
in an unstructured way. The information is
supported by limited evidence and the The algorithms may have the same
relationship to the evidence may not be time complexity but this does not mean
clear. they take the same time to execute on
the same data set.
0 marks Insertion sort generally performs
No attempt to answer the question or quicker than bubble sort and is
response is not worthy of credit. therefore preferable. (Neither scale
well however.)
Both algorithms have a space
complexity of O(1). This is because
both algorithms are inplace (i.e. all
sorting takes place within the actual
data).
Both have a time complexity of O(n2)
as a consequence of their nested
loops.

(NB last two points are only likely to


appear in the very highest mark
answers.)

Examiner’s Comment:
Most candidates achieved some credit,
especially for a description of the bubble
sort. Fewer candidates could compare the
relative merits of both bubble and insertion
sort in terms of the best / average / worse
case.

Total 9

© OCR 2023. You may photocopy this page. 55 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

9 a 1 mark per bullet 2


AO1.2
By reference will change the actual (1)
contents of the array in the main AO2.2
program// when control returns to the (1)
main program the array will be sorted
By value would create a copy and not
change the original // when control
returns to the main program the array
will not be sorted
By value the array is local to the
function.
By reference will use less memory

b 1 mark pet bullet to max 3 3


AO1.2
Descending order (1)
Line 07 AO2.2
(dataArray[tempos]<temp) has (2)
the comparison…
…that checks if current position is less
than item to insert and…
…breaks out of loop when current
position is less than or equal to item to
insert

Total 5

© OCR 2023. You may photocopy this page. 56 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

10 i 1 mark per row (after first row) 5


AO2.2
(5)
100 22 5 36 999 12 Examiner’s Comments
22 100 5 36 999 12 1 mark
5 22 100 36 999 12 1 mark Candidates should be encouraged to
5 22 100 36 999 12 1 mark demonstrate sorting algorithms through the
5 12 22 36 100 999 1 mark use of clear diagrams that show the
steps/passes in the sorting algorithm.
Where candidates used verbose text, it
often made it far harder to follow whether
or not the correct sorting algorithm had
been applied. Most candidates did
implement an insertion sort, but some did
describe bubble or merge sorts instead.

ii 1 mark per bullet to max 7 7


AO1.1
Repeat (2)
Calculating an array midpoint… AO1.2
…by adding the array lower bound to (3)
the array upper bound, dividing by 2 AO2.1 Examiner’s Comments
and rounding (1)
Compare array midpoint with value to AO2.2 The paper title is ‘Algorithms and
search for… (1) programming’. Binary search is a standard
…if equal set found flag to true algorithm that should be fully understood
…if array midpoint < value to search by candidates, and candidates should be
for, change lowerbound to equal able to program it. Many candidates
midpoint + 1 produced very vague descriptions that
…if array midpoint > value to search were far too general to credit at this level.
for, change upperbound to equal Candidates needed to be able to discuss
midpoint - 1 how the upper and lower bound pointers
Until lowerbound is greater than or are used in this algorithm (or equivalent for
equal to upperbound recursive solutions).
Return/output found flag

© OCR 2023. You may photocopy this page. 57 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

iii 1 mark per bullet 4


AO1.2
Setting variable to start at 0 (1)
Suitable while structure (endwhile or AO3.1
clear indentation) (1)
looping 50 times AO3.2
Incrementing the variable within the (2)
loop

e.g. 1 Examiner’s Comments


function searchItem(dataItem)

count = 0 It was a little disappointing to see a number


while count < 50
of candidates using variations on for loops
rather than rewriting the code using a while
if dataArray(count) == dataItem then
loop as required. A significant number of
return(count) candidates still struggled to demonstrate a
endif coherent logical response that would work
count = count + 1
for something that is relatively simplistic,
thus showing a lack of proficiency in coding
practice.
endwhile

return(-1)

endfunction

e.g. 2
function searchItem(dataItem)

count = 0

while count < 50 and


dataArray[count]!=dataItem

count = count + 1

endwhile

if count==50

count=-1

endif

return(count)

endfunction

Total 16

© OCR 2023. You may photocopy this page. 58 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

11 a i 1 mark for each correct item in bold 3 answers must be in the correct case as
AO1.1 given
(3) e.g. currentData

Examiner’s Comment:
Many candidates found it difficult to apply
the logic required to calculate the correct
solution. Stronger candidates could do so
even if they did not know the algorithm for
insertion sort.

ii 1 mark for contents of each row in table 6 … each row is dependent upon the
AO2.1 preceding row being correct
(6)

Examiner’s Comment:
Some candidates confused insertion sort
with other sorting algorithms, but many
candidates gave good answers in
diagrammatic form. Answers in
diagrammatic form after each pass of the
loop were often far clearer than prose
descriptions. This form of answer should
be encouraged.

b i O(n) 1
AO1.1
(1)

ii 1 mark per bullet to max 3 3 B(ii) dependent upon b(i) being correct
AO1.2 i.e. answers for O(n) only
(3)
The best case is for a sorted list (O(n))
As the number of elements increases Accept appropriate graph for bullet points
… the number of steps increases in a 2 and 3
linear fashion

Examiner’s Comment:
Whilst many candidates had some
knowledge of 'Big O' notation fewer could
apply it correctly within the context given.

© OCR 2023. You may photocopy this page. 59 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

Total 13

12 i One item at a time / serially … 3


…moved into correct position… Do not allow swap(ped) or pivots
…until all items in list checked
Allow two lists.

One item at a time taken from 1st list…


…and inserted into 2nd list…
…in the correct place.

Examiner's Comments

There were quite a few very muddled


answers to this question, those that were
not muddled, were just plain wrong. A large
proportion of candidates either were
swapping for a bubble sort or using pivots;
neither of which were what was required.

ii 4 Method must be demonstrated somehow -


circles, underlining, description e.g. “insert
12” etc
Must be an insertion sort

1 mark per correct row after row 1 in Do not allow swap(ped) or pivots
sequence to max 4

Examiner's Comments

Those who knew what an insertion sort


was got this correct, a fair percentage used
quick sorts or bubble sorts and as such did
not receive any marks.

iii Less efficient/takes longer for large 1


sets of data Examiner's Comments

A lot of unnecessarily vague answers who


did not get an easy mark.

Total 8

© OCR 2023. You may photocopy this page. 60 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

13 i 1 mark for each set of 2 moves 3 Allow follow through if one move is
incorrect

02174356
01274356 (1)
01247356
01234756 (1)
01234576
01234567 (1)

© OCR 2023. You may photocopy this page. 61 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

ii 1 mark per bullet to max 6 6 If no description i.e. the candidate has just
shown the quick sort, max 4 marks.
Uses divide-and-conquer (1)
First item becomes pivot / 2 is the pivot
(1)
Compare each item to the pivot (e.g.
compare 0 to 2, then 1 to 2) (1)
Make two lists, 1 with less than the
pivot… (0, 1) (1)
… 1 with more than the pivot
(7,4,3,5,6) (1)
Quick sort the new lists (1)
Recombine the sub-lists (1)

OR
Example of alternative quicksort method

marks for:

Uses divide-and-conquer (1)


Highlight first list element as start
pointer, and last list element as end
pointer
Repeatedly compare numbers being
pointed to…
…if incorrect, swap and move end
pointer
…else move start pointer
Split list into 2 sublists
Quick sort each sublist
Repeat until all sublists have only 1
number
Combine sublists

© OCR 2023. You may photocopy this page. 62 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

Total 9

© OCR 2023. You may photocopy this page. 63 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

14 a 1 mark for any example 1 AO1.2


e.g. (1)

Data is not sorted


Item you are looking for is the first item
in the list
Small number of items

b i 1 mark for each number/statement up to a 6 AO1.2


maximum of 6 marks: (2) AO3.3
(4)
function
binarySearch(dataArray:byref,
upperbound, lowerbound,
searchValue)
while true
middle = lowerbound +)
((upperbound – lowerbound))
DIV 2)
if upperbound < lowerbound
then
return -1
else
if dataArray[middle] <
searchValue then
lowerbound = middle + 1
elseif dataArray[middle] >
searchValue then
upperbound = middle - 1
else
return middle
endif
endif
endwhile
endfunction

ii Do…until // repeat…until // post condition 1 AO1.2


(1)

© OCR 2023. You may photocopy this page. 64 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

c 1 mark for each tick up to a maximum of 6 6 AO1.1


marks (6)
Worst-case space complexity:

Binary Linear
search search
O(log(n))
O(1) ✓ ✓
O(n)
Best-case space complexity:

Binary Linear
search search
O(log(n))
O(1) ✓ ✓
O(n)

Average time complexity:

Binary Linear
search search
O(log(n)) ✓
O(1)
O(n) ✓

Total 14

© OCR 2023. You may photocopy this page. 65 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

15 i 1 mark per bullet up to a maximum of 3 3


marks:
A02.1
5 (Jimmy) (3)
8 (Siad)
9 (Tommy)

ii 1 mark per bullet up to a maximum of 2 2


marks, e.g:
A01.2
Efficient (2)
...as does not need to search every
single element/uses divide and
conquer

iii Linear Search / Serial Search 1

A02.1
(1)

iv The items are in alphabetical order / 1


the items are sorted
A02.1
(1)

Total 7

16 i The data needs to be sorted / in 1


alphabetical order AO2.1 Examiner’s Comments
(1)
Most candidates knew that the list had to
be sorted before a binary search could be
performed.

ii 1 mark per bullet to max 4 4


AO2.1
Start at the first item (Cavalry) (2)
Compare with departure station ‘Bridge AO2.2
Heights’ (2)
If matched, report found Examiner’s Comments
Otherwise continue to the next item in
list (Bridge) The majority of candidates described a
Continue until item found, or end of list linear search, but some described a binary
reached… search by mistake. Where candidates did
and then False returned describe a linear search, they generally did
so with sufficient precision.

Total 5

© OCR 2023. You may photocopy this page. 66 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

17 Algorithm, max 1 3 No marks for justification if linear has not


AO1.1 been identified
(1)
linear AO2.1
(2)
Justification, 1 mark per bullet to max 2

Items do not have to be in a specific


order

Binary needs items in order Examiner’s Comment:


Many candidates correctly identified a
linear search and could justify the need for
it. However, a lot of candidates did answer
binary search without appreciating that the
data set needed to be in order first.

Total 3

© OCR 2023. You may photocopy this page. 67 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

18 Mark Band 3 – High level (7-9 marks) 9 AO1: knowledge and understanding
The candidate demonstrates a thorough Indicative content
knowledge and understanding of
concurrent processing; the material is
generally accurate and detailed. Carrying out more than one task at a
The candidate is able to apply their time
knowledge and understanding directly and Multiple processors
consistently to the context provided Each processor performs
(searching algorithms). simultaneously
Evidence/examples will be explicitly Each processor performs tasks
relevant to the explanation. independently
The candidate provides a thorough
discussion which is well balanced. and/or
Evaluative comments are consistenly
relevant and well considered.
A program has multiple threads
There is a well-developed line of reasoning Each thread starts and ends at
which is clear and logically structured. The different times
information presented is relevant and Each thread overlaps
substantiated. Each thread runs independently

Mark Band 2 – Mid level (4-6 marks) AO2: Application


The candidate demonstrates reasonable
knowledge and understanding of
concurrent processing; the material is Each processor/thread performs a
generally accurate but at times search in a different direction
underdeveloped. Rather than going down one path, go
The candidate is able to apply their down 2+
knowledge and understanding directly to E.g. apply different searches
the context provided although one or two simultaneously - perform breadth- first
opportunities are missed. (searching and depth-first simultaneously
algorithms) Evidence/examples are for the E.g. A* take the two shortest routes at
most part implicitly relevant to the each decision point, update same table
explanation. Linear search can have multiple
The candidate provides a reasonable processors searching different areas at
discussion, the majority of which is the same time.
focused. Evaluative comments are, for the Binary search doesn't benefit from an
most part appropriate, although one or two increase in speed with additional
opportunities for development are missed. processors.
There is a line of reasoning presented with
some structure. The information presented AO3: Evaluation
is in the most part relevant and supported Candidates will need to evaluate the
by some evidence benefits and drawbacks of concurrent
processing in searching e.g.
Mark Band 1 – Low Level (1-3 marks)
The candidate demonstrates a basic
knowledge of concurrent processing with Possibly find solution faster
limited understanding shown; the material Takes up more memory
is basic and contains some inaccuracies. Increase program throughput

© OCR 2023. You may photocopy this page. 68 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

The candidates makes a limited attempt to May waste time investigating inefficient
apply acquired knowledge and solutions
understanding to the context provided More difficult to program especially to
(searching algorithms). cooperate
The candidate provides a limited More memory intensive
discussion which is narrow in focus. Linear search scales very with
Judgements if made are weak and additional processors
unsubstantiated. Binary search can perform better on
The information is basic and comunicated large data sets with one processor than
in an unstructured way. The information is linear search with many processors
supported by limited evidence and the
relationship to the evidence may not be
clear.

0 marks
No attempt to answer the question or
response is not worthy of credit.

Total 9

© OCR 2023. You may photocopy this page. 69 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

19 a Find the middle point in the list / 21 / 4 Some marks such as the comparison may
element 4 be by implication if the candidate’s logic
Compare it to the value 47, false works
Is 47 greater than middle point, true
New subset is 46-51 / change lower Must refer to the list given in the question
bound to 46 / element 5 i.e. not a generic description
Find the middle of the new subset / 47 /
element 6 Is this value equal to 47, true Examiner's Comments
Search finishes
In general, many candidates had an
understanding of how a binary search
operated. Unfortunately, some gave a
generic description rather than answering
the specific question which required the
candidate to illustrate how a binary search
would operate on a specific data set. Some
candidates drew concise and elegant
diagrams with appropriate annotations that
made their answers much clearer than
those who wrote prose at great length.

© OCR 2023. You may photocopy this page. 70 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

b Finding midPoint and correctly 8 Max 8 marks


checking if midPoint value is target
value ...
... and if so returning true Note: candidates may have given a
Correctly checking that all elements recursive algorithm and this should is
have been checked ... perfectly acceptable.
... and if so returning false
Identify top or bottom of list ... Examiner's Comments
... if top then leftPtr set/passed as
midPoint + 1 ... The Binary Search is one of the algorithms
... if bottom then rightPtr set/passed specifically identified in the specification
as midPoint – 1 that candidates need to be able to program
Correct use of indentation (AO2.1) and understand. It is a difficult algorithm to
code correctly and only the most able
Example iterative example candidates managed to produce a strong
response to give the degree of accuracy
required. Many candidates wrote in
structured English which was not
acceptable – the question specifically
required a pseudocode solution.
Candidates are not expected to be able to
write pseudocode in the form given by
OCR in the specification appendix, and
variations from various programming
languages were taken into account.
However, the overall ability to write
pseudocode proved to be a key
differentiator and many candidates should
aim to improve their ability to write
pseudocode before the A2 examination.

Total 12

© OCR 2023. You may photocopy this page. 71 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

20 i Compare 607 with 500 3 Must use values given


Compare 607 with 750
Compare 607 with 625+/-1 Examiner's Comments
or
go to middle value 500 / 502 This was one of the questions that required
compare value with 607 an answer in context and many students
discard first half / repeat in second half of did poorly as a result of not contextualising
set their response. Centres should emphasise
to candidates that they need to think about
the context of their answer if the question
stem requires it.

ii Compare 607 with 2 3 Must use values given


Compare 607 with 4
Compare 607 with 6 Examiner's Comments
or
Start at 2 This question also suffered from
Compare with 607 candidates either not reading the question
Go to 4 (& repeat comparison… etc) properly or not contextualising their
response.

iii Binary search discards half data at each 2 Examiner's Comments


step
Serial search discards one data item at In the main a well answered question, any
each step / each item in turn candidates who did not gain marks for this
probably lost them for being too vague in
their answer; this was an easy question but
required a full answer to justify the mark.

iv Advantage: 2 Examiner's Comments


Generally faster (in large set of data)
Disadvantage: Well answered by most candidates who
Values must have been sorted / values obtained one mark with the more able
must be in order candidates getting the second mark.

Total 10

© OCR 2023. You may photocopy this page. 72 of 73 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

21 a 4 For 4 marks – 1 mark for each correct


entry.

b As x (or the size of the array) 1 For 1 mark.


increases, the rate at which y (or the
number of checks needed) increases
more slowly (1).
The inverse of exponential growth (1).
The rate of increase is a logarithmic
function of the size of the array (1).

c If the array is very small. (1) 1 For 1 mark.


If the item being searched for is very
close to the start of the array. (1)

Total 6

© OCR 2023. You may photocopy this page. 73 of 73 Created in ExamBuilder

Powered by TCPDF (www.tcpdf.org)

You might also like