Sort Binary
Sort Binary
1. Use the binary search algorithm to try to locate the name NIGEL in the following alphabetical list.
Clearly indicate how you chose your pivots and which part of the list is being rejected at each
stage.
1. Bhavika
2. Clive
3. Elizabeth
4. John
5. Mark
6. Nicky
7. Preety
8. Steve
9. Trevor
10. Verity
(Total 4 marks)
2. 650 431 245 643 455 134 710 234 162 452
(a) The list of numbers above is to be sorted into descending order. Perform a Quick Sort to
obtain the sorted list, giving the state of the list after each pass, indicating the pivot
elements.
(5)
The numbers in the list represent the lengths, in mm, of some pieces of wood. The wood is sold in
one metre lengths.
(b) Use the first-fit decreasing bin packing algorithm to determine how these pieces could be
cut from the minimum number of one metre lengths. (You should ignore wastage due to
cutting.)
(4)
(c) Determine whether your solution to part (b) is optimal. Give a reason for your answer.
(2)
(Total 11 marks)
3.
Hajra Vicky Leisham Alice Nicky June Sharon Tom Paul
(H) (V) (L) (A) (N) (J) (S) (T) (P)
(a) Use a quick sort to produce the list of names in ascending alphabetical order.
(b) Use the binary search algorithm on your list to locate the name Paul.
(4)
(Total 8 marks)
The numbers in the list represent the weights, in kilograms, of seven statues. They are to be
transported in crates that will each hold a maximum weight of 60 kilograms.
(a) Calculate a lower bound for the number of crates that will be needed to transport the
statues.
(2)
(b) Use the first-fit bin packing algorithm to allocate the statues to the crates.
(3)
(c) Use the full bin algorithm to allocate the statues to the crates.
(2)
(d) Explain why it is not possible to transport the statues using fewer crates than the number
needed for part (c).
(2)
(Total 9 marks)
5. A builder is asked to replace the guttering on a house. The lengths needed, in metres, are
0.6, 4.0, 2.5, 3.2, 0.5, 2.6, 0.4, 0.3, 4.0 and 1.0
(a) Carry out a quick sort to produce a list of the lengths needed in descending order. You
should show the result of each pass and identify your pivots clearly.
(5)
(b) Apply the first-fit decreasing bin-packing algorithm to your ordered list to determine the
total number of 4 m lengths needed.
(4)
(c) Does the answer to part (b) use the minimum number of 4 m lengths? You must justify your
answer.
(2)
(Total 11 marks)
(a) Given that S = 25 000, complete the table in the answer book to show the results obtained at
each step when the algorithm is applied.
You may not need to use all the lines in this table
(5)
This algorithm is designed to model a possible system of income tax, T, on an annual salary, £S.
(b) Write down the amount of income tax paid by a person with an annual salary of £ 25 000.
(1)
(c) Find the maximum annual salary of a person who pays no tax.
(1)
(Total 7 marks)
7. 32 45 17 23 38 28 16 9 12 10
The numbers in the list above represent the lengths, in metres, of ten lengths of fabric. They are to
be cut from rolls of fabric of length 60m.
(b) Use the first-fit bin packing algorithm to determine how these ten lengths can be cut from
rolls of length 60m.
(4)
(c) Use full bins to find an optimal solution that uses the minimum number of rolls.
(3)
(Total 9 marks)
(a) Use the quick sort algorithm to sort the above list into alphabetical order.
(5)
(b) Use the binary search algorithm to locate the name Louis.
(4)
(Total 9 marks)
(a) Use a quick sort to produce a list of these names in ascending alphabetical order. You must
make your pivots clear.
(5)
(b) Use the binary search algorithm on your list from part (a) to try to locate the name „Hugo‟.
(4)
(Total 9 marks)
10. 29 52 73 87 74 47 38 61 41
The numbers in the list represent the lengths in minutes of nine radio programmes. They are to be
recorded onto tapes which each store up to 100 minutes of programmes.
(a) Obtain a lower bound for the number of tapes needed to store the nine programmes.
(2)
(b) Use the first-fit bin packing algorithm to fit the programmes onto the tapes.
(3)
(c) Use the first-fit decreasing bin packing algorithm to fit the programmes onto the tapes.
(3)
(Total 8 marks)
Start
Let A = 0
Input x, y
Is x No
A=A+y
even?
Yes
x=x-1
No
x= x÷2 Is x = 0?
Yes
y = 2y Output A
Stop
(a) Given that x = 54 and y = 63, complete the table below to show the results obtained at each
step when the algorithm is applied.
(7)
1. Bhavika
2. Clive
3. Elizabeth
4. John
5. Mark
6. Nicky
7. Preety
8. Steve
9. Trevor
10. Verity
(Total 4 marks)
13. 52 48 50 45 64 47 53
The list of numbers above is to be sorted into descending order. Perform a bubble sort to obtain
the sorted list, giving the state of the list after each completed pass.
(Total 4 marks)
Start
Let n = 0
Let A = (1 + 5) ÷ 2, to 3 decimal places.
Let B = (1 – ÷ 2, to 3 decimal places.
Let n = n + 1
Output E
No Is
n > 4?
Yes
Stop
(a) Complete the table below recording the results of each step as the algorithm is applied.
(Notice that values of A, B, C and D are to be given to 3 decimal places, and the values of E
to 1 significant figure.)
You may not need to use all the rows in this table.
(8)
15.
Ali 74
Bobby 28
Eun-Jung 63
Katie 54
Marciana 54
Peter 49
Rory 37
Sophie 68
The table shows the marks obtained by students in a test. The students are listed in alphabetical
order. Carry out a quick sort to produce a list of students in descending order of marks. You
should show the result of each pass and identify your pivots clearly.
(Total 5 marks)
16. 650 431 245 643 455 134 710 234 162 452
(a) The list of numbers above is to be sorted into descending order. Perform a Quick Sort to
obtain the sorted list, giving the state of the list after each pass, indicating the pivot
elements.
(5)
The numbers in the list represent the lengths, in mm, of some pieces of wood. The wood is sold in
one metre lengths.
(b) Use the first-fit decreasing bin packing algorithm to determine how these pieces could be
cut from the minimum number of one metre lengths. (You should ignore wastage due to
cutting.)
(4)
(a) Using the quick sort algorithm, perform one complete iteration towards sorting these
numbers into ascending order.
(2)
(b) Using the bubble sort algorithm, perform one complete pass towards sorting the original
list into descending order.
(2)
(c) Use the binary search algorithm to locate the number 73 in this list.
(4)
(Total 8 marks)
18.
1. Glasgow
2. Newcastle
3. Manchester
4. York
5. Leicester
6. Birmingham
7. Cardiff
8. Exeter
9. Southampton
10. Plymouth
A binary search is to be performed on the names in the list above to locate the name Newcastle.
(a) Explain why a binary search cannot be performed with the list in its present form.
(1)
(b) Using an appropriate algorithm, alter the list so that a binary search can be performed. State
the name of the algorithm you use.
(4)
(c) Use the binary search algorithm on your new list to locate the name Newcastle.
(4)
(Total 9 marks)
START
Input a
a
Let c = b
YES
Output b
Is NO
a = b? Let a = c
YES
END
The diagram above describes an algorithm in the form of a flow chart, where a is a positive
integer.
List P, which is referred to in the flow chart, comprises the prime numbers 2, 3, 5, 7, 11, 13, 17, ...
(a) Starting with a = 90, implement this algorithm. Show your working in the table below.
You may not need to use all the rows in this table.
(7)
(c) Write down the final value of c for any initial value of a.
(1)
(Total 10 marks)
20. Nine pieces of wood are required to build a small cabinet. The lengths, in cm, of the pieces of
wood are listed below.
(a) The first fit decreasing algorithm is used to determine how many of these planks are to be
purchased to make this cabinet. Find the total cost and the amount of wood wasted.
(5)
Planks of wood can also be bought in 1.5 m lengths, at a cost of £4 each. The cabinet can be built
using a mixture of 1 m and 1.5 m planks.
(b) Find the minimum cost of making this cabinet. Justify your answer.
(4)
(Total 9 marks)
21. The following list gives the names of some students who have represented Britain in the
International Mathematics Olympiad.
Roper (R), Palmer (P), Boase (B), Young (Y), Thomas (T), Kenney (K), Morris (M),
Halliwell (H), Wicker (W), Garesalingam (G).
(a) Use the quick sort algorithm to sort the names above into alphabetical order.
(b) Use the binary search algorithm to locate the name Kenney.
(4)
(Total 9 marks)
22. 25 22 30 18 29 21 27 21
(a) (i) Perform the first pass of a bubble sort, giving the state of the list after each exchange.
(ii) Perform further passes, giving the state of the list after each pass, until the
algorithm terminates.
(5)
The numbers represent the lengths, in cm, of pieces to be cut from rods of length 50 cm.
(b) (i) Show the result of applying the first fit decreasing bin packing algorithm to this
situation.
(ii) Determine whether your solution to (b) (i) has used the minimum number of 50 cm
rods.
(4)
(Total 9 marks)
Start
A=1
A=A+1
60
B=
A
Is B an No
integer?
Yes
Print A
Is A = 60?
No
Yes
End
60
Is B = an integer?
A
A Yes or No A Yes or No
1 31
2 32
3 33
4 34
5 35
6 36
7 37
8 38
9 39
10 40
11 41
12 42
13 43
14 44
15 45
16 46
17 47
18 48
19 49
20 50
21 51
22 52
23 53
24 54
25 55
26 56
27 57
28 58
29 59
30 60
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
1 10
1. 2 = 6 Nicky M1
reject top of list
7 10
2 = 9 Trevor A1
reject bottom of list
7 8
2 = 8 Steve A1
reject bottom of list
2. (a) E.g:
650 431 245 643 455 710 234 162 452 134 M1
650 643 710 455 431 245 234 162 452 134 A1
650 710 643 455 431 245 452 234 162 134 A1 ft
710 650 643 455 431 452 245 234 162 134 A1 ft
710 650 643 455 452 431 245 234 162 134 A1
(b) Bin 1 710 + 245 Bin 3 643 + 162 + 134 Bin 5 431 M1A1
4116
(c) = 4.116 5 bins needed optimal M1A1(ft)2
1000
[11]
3. (a)
H V L A N J S T P (N) M1
H L A J N V S T P (A, T) A1
A H L J N S P T V (L, P) A1 ft
A H J L N P S T V (J)
A H J L N P S T V A1 cso 4
1M1: quick sort, pivots, p, chosen and two sublists one <p one >p.
1A1: first pass correct and next pivots chosen correctly/consistently.
2A1ft: second pass correct, next pivots correctly/consistently chosen.
3A1: all correct, cso.
1 9
1st choice 5 Nicky, reject 1 – 5
2
(b) M1 A1
6 9
2nd choice 7.5 8 Tom, reject 8 – 9
2
A1
6 7
3rd choice 6.5 7 Sharon, reject 7
2
4th choice 6 Paul name found A1 cso4
Note
Alternative solutions
Middle right
H V L A N J S T P (N) M1
H L A J N V S T P (A T) A1
A H L J N S P T V (L P) A1ft
A H J L N P S T V (J)
A H J L N P S T V A1cso
list sorted
Middle left
H V L A N J S T P (N) M1
H L A J N V S T P (L S) A1
H A J L N P S V T (A V) A1ft
A H J L N P S T V (H)
A H J L N P S T V A1cso
239
4. (a) e.g. total weight is 239, lower bound is 3.98 so 4 bins. M1 A12
60
Note
Note
Note
1M1: Attempt to find two full bins and allocate at least 6 values
1A1: cao
(d) There are 5 items over 30. No two of these 5 can be paired B2, 1, 02
in a bin, so at least 5 bins will be required.
Note
5. (a)
0.6 4.0 2.5 3.2 0.5 2.6 0.4 0.3 4.0 1.0 2.6
4.0 3.2 4.0 2.6 0.6 2.5 0.5 0.4 0.3 1.0 3.2 0.4 M1
4.0 4.0 3.2 2.6 0.6 2.5 0.5 1.0 0.4 0.3 4.0 0.5 A1
4.0 4.0 3.2 2.6 0.6 2.5 1.0 0.5 0.4 0.3 2.5 A1ft
4.0 4.0 3.2 2.6 2.5 0.6 1.0 0.5 0.4 0.3 1.0 A1ft
4.0 4.0 3.2 2.6 2.5 1.0 0.6 0.5 0.4 0.3 A1 cso 5
Notes
4A1 cso.
(b) Length 1: 4
Length 2: 4
Note
Length 1: 4
Length 2: 4
Length 5: 2.5
Note
Alternate
Sorting into ASCENDING order (full marks if then reversed, otherwise MISREAD)
Middle left
0.6 4.0 2.5 3.2 0.5 2.6 0.4 0.3 4.0 1.0 (pivot 0.5)
0.4 0.3 0.5 0.6 4.0 2.5 3.2 2.6 4.0 1.0 (pivots 0.4, 3.2)
0.3 0.4 0.5 0.6 2.5 2.6 1.0 3.2 4.0 4.0 (pivots 2.5, 4.0)
0.3 0.4 0.5 0.6 1.0 2.5 2.6 3.2 4.0 4.0 (pivot 0.6)
0.3 0.4 0.5 0.6 1.0 2.5 2.6 3.2 4.0 4.0
Middle right
0.6 4.0 2.5 3.2 0.5 2.6 0.4 0.3 4.0 1.0 (pivot 2.6)
0.6 2.5 0.5 0.4 0.3 1.0 2.6 4.0 3.2 4.0 (pivots 0.4, 3.2)
0.3 0.4 0.6 2.5 0.5 1.0 2.6 3.2 4.0 4.0 (pivots 0.5, 4.0)
0.3 0.4 0.5 0.6 2.5 1.0 2.6 3.2 4.0 4.0 (pivot 2.5)
0.3 0.4 0.5 0.6 1.0 2.5 2.6 3.2 4.0 4.0 (pivot 1.0)
First (1)
0.6 4.0 2.5 3.2 0.5 2.6 0.4 0.3 4.0 1.0 (pivot 0.6)
0.5 0.4 0.3 0.6 4.0 2.5 3.2 2.6 4.0 1.0 (pivots 0.5, 4.0)
0.4 0.3 0.5 0.6 2.5 3.2 2.6 1.0 4.0 4.0 (pivots 0.4, 2.5)
0.3 0.4 0.5 0.6 1.0 2.5 3.2 2.6 4.0 4.0 (pivot 3.2)
0.3 0.4 0.5 0.6 1.0 2.5 2.6 3.2 4.0 4.0
First (2)
0.6 4.0 2.5 3.2 0.5 2.6 0.4 0.3 4.0 1.0 (pivot 0.6)
0.5 0.4 0.3 0.6 4.0 2.5 3.2 2.6 4.0 1.0 (pivots 0.5, 4.0)
0.4 0.3 0.5 0.6 2.5 3.2 2.6 1.0 4.0 4.0 (pivots 0.4, 2.5)
0.3 0.4 0.5 0.6 1.0 2.5 3.2 2.6 4.0 4.0 (pivot 3.2)
0.3 0.4 0.5 0.6 1.0 2.5 2.6 3.2 4.0 4.0
[11]
S T R R>0? Output
25000 0 17000 Y Line 1
3400 Line 2
7000 Line 3
Y Line 4
4450 Line 5
–5000 Line 6
n Line 7
4450
230
7. (a) 3.83 so 4 needed M1 A12
60
Note
1A1: cso 4.
(b) Bin 1: 32 17 9 M1 A1
Bin 2: 45 12 A1
Bin 3: 23 28 A14
Bin 4: 38 16
Bin 5: 10
2A1: 32, 45, 17, 23, 38, 28, 16, 9 placed correctly.
3A1: cao
Bin 1: 45 12
Bin 2: 38 17
Bin 3: 32 28
Bin 4: 23 16 10 9
A1 for cao.
Bin 2: 38 12 10 M1 A1
Bin 3: 45 9
Bin 4: 23 17 16 A13
Note
8. (a)
M J E K H B L P N D B M1 1A1
B M J E K H L P N D H
B E D H M J K L P N DL 2A1ft
Note
1 10
(b) 2 6 Katie reject left M1
7 10
2 9 Natsuko reject right 1A1
7 8
2 8 Miri reject right 2A1ft
Note
If choosing J M1 ony
Special case
9. (a) e.g.
M L J H K T R I M1
J H I K M L T R A1
H J I K M L R T A1ft
H I J K L M R T A1ft
H I J K L M R T A1cso 5
Note
1M1: quick sort, pivots, p, chosen and two sublists one <p one >p.
If choosing 1 pivot per iteration only M1 only.
1A1: first pass correct and next pivots chosen correctly/consistently.
2A1ft: second pass correct, next pivots correctly/consistently chosen.
3A1ft: third pass correct, next pivots correctly/consistently chosen.
4A1: all correct, cso.
1 8
1st choice 5 Lauren reject right M1 A1
2
1 4
2nd choice 3 John reject right
2
1 2
3rd choice 2 Imogen reject right A1ft
2
Note
1M1: binary search, choosing pivot, rejecting half list. If using unsorted
list, M0. Accept choice of K for M1 only.
1A1: first pass correct, condone „sticky‟pivot here, bod.
2A1ft: second pass correct, pivot rejected.
3A1: cso.
[9]
502
10. (a) = 5.02 so 6 tapes. Ml
100
7 8
2 8 (a)
11.
A x y x even? x = 0?
0 54 63 Y M1A1
27 126 N
126 26 N A1ft
13 252 N
378 12 N M1
6 504 Y
3 1008 N A1ft
1386 2 N
1 2016 N
3402 0 Y A1
A = 3402 B1ft7
13. e.g. 52 48 50 45 64 47 53 M1
52 50 48 54 47 53 45
52 50 54 48 53 47 45 A1
52 54 50 53 48 47 45
64 52 53 50 48 47 45 A1ft
64 53 52 50 48 47 45 A1 4
A1 Final pass and final statement/rewritten list cso – must see whole list
[4]
Notes
Bubble R L
52 48 50 45 64 47 53 M1
64 52 48 50 45 53 47
64 53 52 48 50 45 47 A1
64 53 52 50 48 47 45 A1
L R (ascending – misread) MR
52 48 50 45 64 47 53 M1
48 50 45 52 47 53 64
48 45 50 47 52 53 64 A1
45 48 47 50 52 53 64
45 47 48 50 52 53 64 A1
No further changes – list sorted A1
(4-2 for misread)
RL
52 48 50 45 64 47 53 M1
45 52 48 50 47 64 53
45 47 52 48 50 53 64 A1
45 47 48 52 50 53 64
45 47 48 50 52 53 64 A1
14.
A B n C D E M1
1.618 –0.618 1 1.618 –0.618 1 A1 A1 3
2 2.618 0.382 1 M1 A1ft
3 4.236 –0.236 2 A1ft
4 6.854 0.146 3 A1
5 11.089 –0.090 5 A1 5
Output : 1, 1, 2, 3, 5 A1ft 1
[9]
74 28 63 54 54 49 37 68 54 M1
74 63 54 68 54 28 49 37 54 49 A1
74 63 68 54 49 28 37 63 37
15. e.g. 4
74 68 63 37 28 68 (28) A1ft
74 68 28
74 68 63 54 54 49 37 28 sort complete A1
(i)
74 28 63 54 54 49 37 68 54 M1
74 63 68 54 28 54 49 37 63 49 A1
74 68 63 54 49 28 37 68 37 (54)
74 68 54 37 28 A1ft
(ii)
74 28 63 54 54 49 37 68 54 M1
74 63 54 68 54 28 49 37 63 49 A1
74 68 63 54 49 28 37 74 28 (54)
74 68 54 37 28 A1ft
(iii)
74 28 63 54 54 49 37 68 54 M1
74 63 68 54 28 54 49 37 63 54 A1
74 68 63 54 28 49 37 74 49
74 68 49 28 37 28 (68)
37 28 (37) A1ft
1st in list
(iv)
(a)
MR
74 28 63 54 54 49 37 68 54 M1
28 54 49 37 54 74 63 68 49 63 A1
28 37 49 54 63 74 68 37 68 (54)
28 37 54 68 74 A1ft
(b)
MR
74 28 63 54 54 49 37 68 54 M1
28 49 37 54 74 63 54 68 49 54 A1
28 37 49 54 74 63 68 37 63
28 37 63 74 68 68 (28)
68 74 A1ft
(c)
MR
74 28 63 54 54 49 37 68 54 M1
28 54 49 37 54 74 63 68 54 63 A1
28 49 37 54 63 74 68 49 74
28 37 49 68 74 28
28 37
A1ft
(d)
(b) Bin 1 710 + 245 Bin 3 643 + 162 + 134 Bin 5 431 M1 A1
Bin 2 650 + 234 Bin 4 455 + 452 A1ft A1
(c) eg.
4116
= 4.116 5 bins needed optimal M1 A1ft
1000
[11]
(b) 56 45 79 46 37 90 81 51 18
or 90 45 56 37 79 46 18 81 51 M1A1 2
1 11
(c) 2 = 6 value 44 discard top M1
7 11
2 = 9 value 71 discard top A1
10 11
2 = 11 value 94 discard bottom A1
list reduces to 10th value. This is 73 so
73 has been located as the 10th value A1 4
[8]
Bubble sort
G N M Y L B C E S P
B G N M Y L C E P S 1st pass
B C G N M Y L E P S 2nd pass
B C E G N M Y L P S 3rd pass
B C E G L N M Y P S 4th pass
B C E G L M N P Y S 5th pass
B C E G L M N P S Y 6th pass
No more changes
Quick sort
G N M Y L B C E S P
B G N M Y L C E S P 1st pass
B G C E L N M Y S P 2nd pass
B C G E L N M S P Y 3rd pass
B C E G L N M P S Y 4th pass
B C E G L M N P S Y 5th pass
B C E G L M N P S Y 6th pass
A1 A1ft
No more changes No sublists > 2 + no more changes A1cso 4
(c) 1 2 3 4 5 6 7 8 9 10
B C E G L M N P S Y
[10 1]
= 6 Manchester discard first half of list and pivot M1 A1
2
[7 10]
= 9 Southampton discard last half of list and pivot
2
[7 8]
=8 Plymouth discard last half of list and pivot A1ft
2
Final term 7 Newcastle word found at 7 A1cso 4
[9]
19. (a)
a b c Integer? Output a = b?
list
90 2 45 Yes 2 No M1
45 2 22.5 No A1
45 3 15 Yes 3 No A1ft
(c) C=1 B1 1
[10]
Cost £11 A1
1.5m lengths better value than 1m lengths to use as many as possible A1 4
[9]
R P B Y T K M H W G M1
A1
B H G K R P Y T M W
A1 ft
B G H K R P M T Y W A1 ft
B G H K M P R T W Y A1 ft
B G H K M P R T W Y
10 1
(b) 2 = 6 Palmer; reject Palmer Young M1 A1
5 1
2 = 3 Halliwell; reject Boase Halliwell A1
60
23. Is B = an integer?
A
A Yes or No A Yes or No
1 Yes 31 No
2 Yes 32 No
3 Yes 33 No
4 Yes 34 No
5 Yes 35 No
6 Yes 36 No
7 No 37 No
8 No 38 No
9 No 39 No
10 Yes 40 No
11 No 41 No
12 Yes 42 No
13 No 43 No
14 No 44 No
15 Yes 45 No
16 No 46 No
17 No 47 No
18 No 48 No
19 No 49 No
M1
A3 (1 eeoo)
3. This proved a good starter and was well answered by many candidates with around 55% getting full marks. The quick
sort was well handled although some candidates did not choose their pivots consistently. A few candidates did not
select a pivot when they had a two element sublist in the correct order – often HJ, and a minority sorted the list into
reverse alphabetical order. It was alarming that some candidates only selected one pivot per iteration, so, in effect, just
dealing with one sublist at a time. Candidates must show that they are selecting one pivot, per sublist, per iteration; that
is what makes this algorithm so powerful. A number of candidates did not have the final list in alphabetical order.
Many candidates in part (b) lost marks for failing to reject the pivot and number of candidates attempted to use the
original, unsorted list. Some, who tried for a more „minimalist‟ solution, did not make their pivot choice clear, or the
order in which they chose pivots.
4. This was a good source of marks for well-prepared candidates with over 75% gaining at least 7 marks, though the final
part challenged all but the most able.
Part (a) was almost always completed correctly.
Part (b) was often well done, although some used first fit decreasing and 29 was sometimes either omitted from the list
or changed to 39.
Most candidates were able to complete part (c) correctly but a few only listed one full bin.
In part (d) many incorrectly stated that the full bin solution was optimal, others made some vague reference to the
statues being too heavy, relatively few attempted a valid numerically based answer and managed to express it clearly.
5. Many candidates scored at least 8 marks here. In part (a) a minority produced an ascending list and failed to reverse it.
Some candidates did not choose their pivots consistently, swapping between middle right and middle left pivots. The
decimals here caused some problems and even though the original list was printed in the answer booklet, a surprising
number of candidates initially lost one item or changed one, most commonly 1.0 became 0.1. Some candidates found
only one pivot per row, with some not explicitly choosing pivots when sublists of length 2 happened to be in order –
most frequently the two 4.0s and the 1.0, 0.6 at the end. Good presentation, with a list spread evenly, in columns, across
the page, helps here. (Vertical listing is rarely successful). Part (b) was generally well done, the two most popular errors
being to put 0.6 in bin 5 or 0.4 in bin 5. A significant number who had sorted the numbers into increasing order in part
(a) proceeded to use a “first fit increasing” method here. In part (c) most candidates calculated the lower bound
correctly. Other candidates correctly stated that since the five largest items were over half a bin in size they could not
share a bin, so at least 5 bins would be needed. A few simply stated „yes‟ without justification, gaining no credit.
6. This question proved accessible to almost all, with very many perfect solutions seen, an improvement in performance
compared with previous examinations. There were only a handful of arithmetic errors here. Most candidates
successfully completed the first few steps of the algorithm. The majority of errors arose from writing down the incorrect
(size of) answer, e.g. –500 instead of –5000. There were some who inserted too many entries in the output column.
Quite a few inserted an expression rather than an amount in then T column (e.g. 0.2R). Despite errors in the output,
most realised that this was the amount they had to show for the amount of income tax paid, earning a follow through
mark in part (b). In part (c) many stated that the maximum was £7999.99 rather than the £8000.
8. This was generally well done. A disappointingly large number of candidates only chose one pivot per iteration, rather
than choosing one pivot per sublist, and some candidates used lengthy methods of presentation that isolated each sublist
in turn, making it difficult to see if they were choosing more than one pivot per iteration. The examiners would advise
candidates to refrain from showing this unnecessary detail and simply indicate the pivots selected at each iteration.
Some candidates did not select a pivot where the sublist was of order two, with the two items being in the correct order,
and some did not consistently pick „middle left‟ or „middle right‟ when the sublist was of even order. Candidates are
reminded that when the items are being transferred to the next line, the order of the items should be preserved, so if item
Y is to the left of item X in the current line, neither of them being a pivot, then Y should be to the left of X in the next
line. The best candidates allowed each item to become a pivot before declaring the sort complete. Some candidates did
not check that their final list was in alphabetical order. In part (b) some candidates tried to apply the algorithm to the
original unsorted list given at the start of (a) and others did not discard the pivot at each stage, but generally the binary
search was very well done. A few candidates selected J as the first pivot, the specification makes it clear that candidates
must take the „middle right‟ where necessary.
9. Part (a) was done with mixed success. The majority of candidates gained full marks or three marks. The most common
errors were to have HIJ after the second pass and neglecting to choose a pivot on the third pass with the entry MR. Most
knew their alphabet, but not all. There was a temptation to go into too much detail about the choice of pivot, to the
extent that examiners were not always sure that more than one pivot was being considered per iteration. It is an
important feature of the quick sort that the number of pivots can potentially double at each iteration, so the selection of
multiple pivots must be clearly shown. Some candidates did not abbreviate the names, by using the initial letter and this
slowed them down.
Part (b) was usually very well done. The most common errors were not rejecting the pivot and not making a decision
when Hannah was left. Some candidates added Hugo to the list and then found him, others confused Hannah and Hugo.
10. This proved an accessible first question and was well answered by many candidates. Some candidates probably spent
too long on this question, drawing out very neat and accurate bar graphs in (b) and (c), where numbers in bins were
perfectly acceptable. Most candidates calculated the lower bound correctly in part (a) although some attempted a full
bin solution and others divided by 9, some having calculated 5.02 rounded down to 5. Apart from the usual omissions of
data, part (b) was usually well answered, the most common slips being to swap the 38 and the 41, or to use the 52 to start
off the second bin. First–Fit increasing was disappointingly often seen in part (c), but those who used the correct
algorithm were usually successful with the only common error being misplacing the 38.
11. Although there were many very good responses seen many candidates seemed to get into difficulty by the end of the
second line. This question requires a methodical, accurate and diligent approach and the examiners were surprised at
the number of candidates who found difficulty following the instructions. 126 was often seen in the second line of A,
the 26 in x was often omitted, as was the 12, some candidates changed the A or y entries too early, or too late, and some
candidates entered superfluous „yes‟ and „no‟ entries in the last two columns. Many candidates compressed their entries
– so that they were no longer „in line‟, others repeated entries, others wrote more than one entry in each box; this made
it difficult to determine the stage at which the candidates were changing the entries. Only the best candidates were able
to give the correct answer in part (b), with „the value of A when x = 0‟, and „LCM‟ being the most popular incorrect
answers – although HCF, HCM and LCF were also seen.
12. This proved a good starter question for the candidates with many gaining full marks. Some candidates were inconsistent
in their pivot choice, the specification requires that they round up. Some incorrectly retained the pivot each time – often
leading to a situation where they selected Nicky twice, once as the first pivot and once as the final pivot. Some
candidates insisted on placing Nigel in the list – or locating the position in which Nigel should be added to the list. The
binary search algorithm is both used to locate an item in the list and to demonstrate its absence. A few candidates
confused binary search and quick sort.
13. This proved a good starter question for the candidates, with the vast majority scoring full marks. Only a few candidates
sorted the list into ascending order, and very few incorrect methods were seen, but a disappointing number of
candidates did not seem to be aware that a bubble sort should be performed consistently in one direction. Amongst
those candidates using the correct method, more marks were lost by those misreading their own writing and changing
one number into another than those lost making errors in applying the algorithm. Some candidates omitted a „stop‟
statement. Candidates were asked to give the state of the list after each pass, but many showed each exchange and some
each comparison, which wasted time, many of these candidates needed to use additional sheets to show all of this
working and many got into time difficulties later on in the paper.
14. Most candidates completed the table but many did not precisely follow the instructions or else had difficulty in using
their calculator correctly. This was therefore disappointingly done. Many candidates did not obey the directions relating
to accuracy, stating an incorrect number of decimal places or significant figures or making rounding errors. Some very
careless calculator work was seen, the values of D should have alternated in sign, but were often negative throughout
15. The vast majority of candidates showed that they understood the concept of quick sort, with very few bubble sorts seen.
Most candidates chose to start with one of the 54‟s as a pivot and a number of candidates were unsure what to do with
the second 54. Some chose 2 pivots initially, or created an incorrect order where the two 54s were next to each other.
However, most candidates dealt well with this situation. Other common errors were: not identifying a pivot towards the
end of the quick sort, where two numbers were already in the correct order, fragmenting the list rather than selecting
pivots concurrently and the regularly seen re-ordering of the sub-lists. Many candidates did not produce a list of
students in order.
16. Some very good answers were seen to part (a), but many candidates produced disappointing attempts. Poor presentation
and lack of concentration accounted for most errors in part (a); there was inconsistent choice of pivots, numbers that
disappeared from the list, numbers that mutated into other numbers and, of course, numbers being reordered in the list.
A large minority sorted the list into ascending order. A number of candidates are only selecting one pivot per pass,
which rather defeats the object of a quick sort. Only a very few Bubble sorts were seen. Candidate would help
themselves hugely by not fixing the position of the pivots until the line after they are selected, this would avoid the need
to try to cram numbers into the ever-decreasing space formed by their previously chosen pivots. Candidates could then
use the whole width of the line each time. Part (b) was usually well done. Some used the first fit algorithm and many put
134 into bin 5 rather than bin 3. Part (c) was often well attempted with the majority of candidates giving a clear,
arithmetical argument.
17. This was generally well done. Many candidates completed the quick sort, wasting time. Some candidates did not
understand the difference between an exchange and a pass in a bubble sort. Most candidates carried out the search well,
but many did not give the location of the value. A large number are still assuming that the item is in the list, making
statements such as „down to one item so found‟. A surprisingly large minority of candidates used the mean of the end
numbers in the remaining list to create a „pivot‟ which is unacceptable.
18. This question was often well answered. Most candidates correctly competed part (a), although a very few stated that the
list should be in ascending rather than alphabetical order. Most could correctly name and use a suitable sorting
algorithm in part (b), although some did not make their stopping statement clear and a few used a shuttle sort (not in this
specification) stating that it was a bubble sort. A surprisingly large minority confused the order of the alphabet with S
and P (and then M and N) most frequently transposed. Part (c) was usually well done but candidates must make their
pivots – and the order in which they select their pivots, clear. Candidates must remember to discard their pivots and note
that the specification instructs them to „round up‟. Once again the stopping/found statement was sometimes missing,
and some candidates assumed the presence of N, stating that once they had got down to 1 term only, that term must be
N.
19. Most candidates were able to make some progress with this question and for a number it was a rich source of marks. In
part (a) the most common error was a failure to „reset‟ the list to 2 after answering „no‟. A surprisingly large number of
candidates did not seem to understand what was meant by the word „integer‟. In part (b) only the most able were able to
recognise the list as the prime factorisation of a, and poor knowledge/understanding of the terms prime, factor and
multiple. Most candidates who completed part (a) correctly were able to answer part (c) correctly.
20. Many candidates scored full marks in part (a); however some candidates used the values in ascending order scoring
zero. There was no need to use a formal sort to put the list in order. Many candidates gave the cost of the wasted wood
rather than the cost of the five planks. In part (b) many candidates found an optimal solution, but many then went on to
consider just the amount of wood wasted, rather than showing that the cost depended upon the value for money of each
plank and therefore maximising the number of 1.5m lengths used.
21. Many candidates were able to gain full marks on this question. The most common errors in part (a) were in re-ordering
the letters in the sub-lists and choosing the pivots inconsistently. A surprising number of candidates seemed unsure of
the alphabet. Part (b) was well done by the majority of candidates. A surprising number tried to use an unsorted list for
their search, gaining no marks and others omitted to discard the pivot. The commonest error was in failing to select
Morris after correctly selecting Palmer then Halliwell. A few candidates did not make the order in which they selected
the pivots clear making it impossible to give credit.
22. Most candidates were able to complete the bubble sort correctly, although a number of shuttle sorts were seen from a
few candidates. A number of candidates did not complete a final pass, (or stated that they had performed a final pass
and found no further exchanges). The majority were able to complete the bin packing but a number were unable to show
that they had used a minimum number of bins, once again the lower bound would have helped here.