GCSE (9-1) Computer Science
Mark Scheme
J277/02: Unit 2.1 Standard Sorting Algorithms
Question Answer Marks Guidance
1a [ "Alan", "Cian", "Ben", "Dave" ]
  • "Dave" moved to the end (the bubble) (1).
  • "Alan" and "Cian" swapped correctly at the start (1).
2
Examiner Note: The largest value must be at the end after Pass 1.
1b
  • The algorithm does not know the list is sorted yet (1).
  • It needs to complete a full pass without making any swaps to set the boolean flag to False (1).
2
2a [ 5, 12, 18, 1, 9 ]
  • 5 and 12 being sorted (1).
  • 18 staying in position (as it is larger than 12) (1).
2
Note: Students often mistakenly sort the whole list. This question asks for the state after the second insertion (index 2).
2b
  • The value 1 is compared to 18, 12, and 5 (Compare) (1).
  • Each value is shifted one position to the right (Shift) (1).
  • 1 is inserted into index 0 (Insert) (1).
3
3a [15] [3] [9] [12] [6] [2] 2
2 marks for individual lists.
1 mark if pairs are shown. J277 requires showing the "Divide" stage down to single items.
3b
  1. Merge pairs -> [3, 15] [9, 12] [2, 6] (1)
  2. Merge groups -> [3, 9, 12, 15] [2, 6] (1)
  3. Final Merge -> [2, 3, 6, 9, 12, 15] (1)
3
4 Merge Sort Advantage: Much faster/more efficient on large lists (1). Time complexity is lower (O(n log n)) compared to Bubble Sort (1).

Bubble Sort Advantage: Easier to write/code (1). Uses less memory (does not create new sub-lists) (1).
4
5a Line 07 1
It checks if scores[i] < scores[i+1], it should be >.
5b Line 06 1
for i = 0 to n - 1 causes out of bounds when accessing i+1.
5c
  • To check if the list is sorted (1).
  • If no swaps occur in a pass, the loop terminates early (efficiency) (1).
2
6 Logic Points:
1. Outer Loop: Iterates from index 1 to end (1).
2. Store Value: current = data[i] (1).
3. Inner Loop Setup: j = i - 1 (1).
4. Comparison: Checks data[j] > current AND j >= 0 (1).
5. Shift: Moves item right data[j+1] = data[j] (1).
6. Insert: Places item data[j+1] = current (1).
6
Accept Pseudocode or Python-style syntax.
7a Insertion Sort 1
7b
  • Insertion sort is very efficient on lists that are already mostly sorted (1).
  • It only has to process the 5 new items, whereas Merge sort would split the whole 1,000,000 again (1).
2
8 It breaks the large list down into smaller sub-lists (1) until each list contains only one item (1). 2
9 while swap == True OR while sorted == False 2
Must imply the loop continues as long as swaps are happening.
10 (a) Comparison: False (or No) (1).
(b) Action: No change / Leave 5 in place (1).
2