Algorithms

From an AS paper

Edexcel

Edexcel · Old spec

A2 June 2025 Q2

EdexcelCurrent spec10 marksAlgorithms

2.

271828182845904523536028747135

The list of ten numbers above is to be sorted into descending order.

(a) Perform a quick sort on the list to obtain the sorted list. You should show the result of each pass and identify the pivots clearly. (4)

A list of \(n\) numbers is to be sorted into descending order using bubble sort.

(b) Determine, in the worst case, the total number of comparisons required to sort the list. Give your answer as a simplified expression in terms of \(n\). (2)

The following algorithm determines an approximation to the value of e

Step 1Start
Step 2Let \(a = 1\)
Step 3Let \(b = 1\)
Step 4Let \(c = 1\)
Step 5Let \(d = a\)
Step 6Let \(c = c \times b\)
Step 7Let \(d = d + \frac{1}{c}\)
Step 8If \(b = 6\) go to Step 11
Step 9Let \(b = b + 1\)
Step 10Go to Step 6
Step 11Output \(d\)
Step 12Stop
(c) Complete the table in the answer book to show the results obtained at each step of the algorithm. (3)

[The table in the answer book has columns headed \(a\), \(b\), \(c\), \(d\). You may not need to use all the rows in this table. It may not be necessary to complete all boxes in each row.]

\(a\)\(b\)\(c\)\(d\)
 
 
(d) Calculate, to 3 significant figures, the percentage error in using the value found in (c) to approximate the value of e (1)

A2 June 2025 Q1

EdexcelCurrent spec5 marksAlgorithms

1.

4.72.95.51.45.82.83.86.55.16.34.1
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 13 (3)
(b) Use the first-fit decreasing bin packing algorithm to determine how the numbers listed above can be packed into bins of size 13 (2)

AS June 2025 Q1

EdexcelAS paperCurrent spec7 marksAlgorithmsMinimum Spanning Trees

1.

16102530131228222320

The list of ten numbers above is to be sorted into ascending order.

(a) Carry out a bubble sort, starting at the left-hand end of the list, to produce the sorted list. You should only give the state of the list after each pass. (3)
Figure 1: weighted network on vertices A to F with arcs AB 13, AC 10, AD 30, BC 12, BE 22, BF 23, CF 20, CD 28, DF 25, EF 16
Figure 1
(b) Use Prim’s algorithm, starting at A, to find the minimum spanning tree for the network in Figure 1. You must list the arcs in the order in which you select them. (2)
(c)
(i) Draw the minimum spanning tree on Diagram 1 in the answer book.
Diagram 1: the vertices A to F of Figure 1 with no arcs
Diagram 1
(ii) Find the weight of the minimum spanning tree. (2)

A2 June 2024 Q1

EdexcelCurrent spec7 marksAlgorithms

1.

17816122419231120134

The eleven numbers listed above are to be packed into bins of size \(n\) where \(n\) is a positive integer. When the first-fit bin packing algorithm is applied to the eleven numbers, the bins are packed as shown below.

Bin 1:17   8   12
Bin 2:16   24
Bin 3:19   11   4
Bin 4:23   13
Bin 5:20
(a) Explain why this packing means that the value of \(n\) must be 40 (1)

The original list of eleven numbers is to be sorted into descending order.

(b) Use a quick sort to obtain the fully sorted list. You must make your pivots clear. (4)
(c) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack the numbers into bins of size 40 (2)

AS June 2024 Q1

EdexcelAS paperCurrent spec9 marksAlgorithms

1.

46.571.3251.564.561

The list of eleven numbers shown above is to be sorted into descending order.

(a) Carry out a quick sort to produce the sorted list. You should show the result of each pass and identify the pivots clearly. (3)
(b) Use the first-fit decreasing bin packing algorithm to pack the numbers into bins of size 10 (3)
(c) Determine whether your answer to part (b) uses the minimum number of bins. You must justify your answer. (2)

A different list of eleven numbers is to be sorted into descending order using a bubble sort. The list after the second pass is

4.55.63.86.75.41.64.89.13.31.71.5
(d) Explain how you know that at least one of the first two passes of the bubble sort was not carried out correctly. (1)

A2 June 2023 Q4

EdexcelCurrent spec12 marksAlgorithms

4. The eleven distinct numbers listed below are to be packed into bins of size 40

15223923\(x\)54182013

It is known that \(x\)

  • is an integer less than 40
  • is the largest number in the list
(a) Explain why it is not possible to pack the numbers into 3 bins of size 40 (1)

Given that it is possible to pack the numbers into 4 bins of size 40

(b) determine the range of values for \(x\) (2)
(c) Use the first-fit bin packing algorithm to determine how the numbers can be packed into bins of size 40 (3)
(d) Carry out a quick sort to produce a list of the numbers in descending order. You should show the result of each pass and identify your pivots clearly. (4)

When the first-fit decreasing bin packing algorithm is applied to the list, neither the 15 nor the 13 is placed in the first bin.

(e) Determine the value of \(x\). You must give reasons for your answer. (2)

A2 June 2023 Q3

EdexcelCurrent spec8 marksAlgorithmsShortest Path

3.

Figure 4: network on A to J with edges AB 23, AC 35, AD 41, BC 8, BE 42, BG 37, CD 7, CE 30, CG 28, CH 45, CF 43, DF 34, DH 32, EG 21, EH 7, EJ 50, FG 11, FH 22, GH 10, HJ 32
Figure 4

Figure 4 represents a network with nodes, A, B, C, D, E, F, G, H and J.

The number on each edge gives the length of the corresponding edge.

(a)
(i) Use Dijkstra’s algorithm to find the shortest path from A to J.
(ii) State the length of the shortest path from A to J. (6)

One application of Dijkstra’s algorithm has order \(n^2\), where \(n\) is the number of nodes in the network.

It takes a computer 0.0312 seconds to find the shortest path from a given start node to a given end node in a network of 9 nodes.

(b) Calculate approximately how long it would take, in minutes, for the computer to find the shortest path from a given start node to a given end node for a network of 9000 nodes. (2)

AS June 2023 Q1

EdexcelAS paperCurrent spec4 marksAlgorithms

1.

6759467140485363455456

The list of eleven numbers shown above is to be sorted into descending order.

Carry out a quick sort to produce the sorted list. You should show the result of each pass and identify the pivots clearly.

A2 June 2022 Q6

EdexcelCurrent spec12 marksAlgorithmsMinimum Spanning Trees

6. The following algorithm determines the number of comparisons made when Prim’s algorithm is applied to \(K_n\)

Step 1Start
Step 2Input the value of \(n\)
Step 3Let \(a = 1\)
Step 4Let \(b = n - 2\)
Step 5Let \(c = b\)
Step 6Let \(a = a + 1\)
Step 7Let \(b = b - 1\)
Step 8Let \(c = c + (a \times b) + (a - 1)\)
Step 9If \(b \gt 0\) go to Step 6
Step 10Output \(c\)
Step 11Stop
(a) For \(K_5\), complete the table in the answer book to show the results obtained at each step of the algorithm. (3)

You may not need to use all the rows in this table. It may not be necessary to complete all the boxes in each row.

\(n\)\(a\)\(b\)\(c\)
    
    
    
    
    
    
    
    
    
    
    
    
    
    

Output: ____________

Figure 4: complete graph on A, B, C, D and E with arcs AB 17, AC 28, AD 24, AE 14, BC 19, BD 21, BE 15, CD 23, CE 20, DE 13
Figure 4

The weights of the ten arcs in Figure 4 are

17212414231315192820
(b)
(i) Starting at the left-hand end of the above list, sort the list into ascending order using bubble sort. You need only write down the state of the list at the end of each pass.
(ii) Find the total number of comparisons performed during the sort. (5)
(c) Find the maximum total number of comparisons required to sort the weights of the 10 arcs of \(K_5\) into ascending order using bubble sort. (1)

It is given that the maximum total number of comparisons required to sort the weights of the arcs of \(K_n\) into ascending order using bubble sort is

\(\lambda n(n - 1)(n + 1)(n - 2)\)

where \(\lambda\) is a constant.

(d) Determine the maximum total number of comparisons required to sort the weights of the arcs of \(K_{50}\) into ascending order using bubble sort. You must make your method and working clear. (3)

A2 June 2022 Q1

EdexcelCurrent spec5 marksAlgorithms

1. A gardener needs the following lengths of string. All lengths are in metres.

4.36.15.14.72.55.93.41.72.10.41.3

She cuts the lengths from balls of string. Each ball contains 10 m of string.

(a) Calculate a lower bound for the number of balls of string the gardener needs.
You must make your method clear. (2)
(b) Use the first-fit bin packing algorithm to determine how the lengths could be cut from the balls of string. (3)

AS June 2022 Q1

EdexcelAS paperCurrent spec9 marksAlgorithmsMinimum Spanning Trees

1.

5544345928374152334247

The list of eleven numbers shown above is to be sorted into ascending order.

(a) Carry out a quick sort to produce the sorted list. You should show the result of each pass and identify your pivots clearly. (4)
Figure 1: weighted network on vertices A to G with arcs AC 55, AB 52, BC 41, BD 47, CD 34, CE 37, CF 33, DE 28, DG 59, EG 42, FG 44
Figure 1
(b) Use Kruskal’s algorithm to find the minimum spanning tree for the network in Figure 1. You should list the arcs in the order in which you consider them. For each arc, state whether or not you are adding it to your minimum spanning tree. (3)
(c)
(i) Draw the minimum spanning tree on Diagram 1 in the answer book.
(ii) State the total weight of the tree. (2)
Diagram 1: the vertices A to G of Figure 1 with no arcs
Diagram 1

A2 October 2021 Q6

EdexcelCurrent spec10 marksAlgorithmsShortest Path

6.

Figure 4: network on A to H with arcs AB 32, AC 16, AD 75, AF 95, BD 33, BE 15, CD 50, CF 70, CG 105, CH 113, DE 17, DG 50, EF 30, FG 25, FH 41, GH 10
Figure 4

In Figure 4 the weights on the arcs represent distances.

(a)
(i) Use Dijkstra’s algorithm to find the shortest path from A to H.
(ii) State the length of the shortest path from A to H. (6)

One application of Dijkstra’s algorithm has order \(n^2\), where \(n\) is the number of nodes in the network. A computer produces a table of shortest distances between any two different nodes by repeatedly applying Dijkstra’s algorithm from each node of the network.

It takes the computer 0.082 seconds to produce a table of shortest distances for a network of 10 nodes.

(b) Calculate approximately how long it will take, in seconds, for the computer to produce a table of shortest distances for a network with 200 nodes. You must give a reason for your answer. (3)
(c) Explain why your answer to part (b) can only be an approximation. (1)

A2 October 2021 Q5

EdexcelCurrent spec10 marksAlgorithms

5.

301252231836101524
(a) The list of ten numbers above is to be sorted into descending order. Use a quick sort to obtain the sorted list. You should show the result of each pass and identify your pivots clearly. (4)

The ten numbers are to be packed into bins of size \(n\), where \(n\) is a positive integer.

When the first-fit bin packing algorithm is applied to the original list of ten numbers, the following allocation is obtained.

Bin 1:30   12   2
Bin 2:5   23   10
Bin 3:18   15
Bin 4:36
Bin 5:24
(b) Explain why the value of the integer \(n\) must be either 44 or 45 (3)
(c) Use the first-fit decreasing bin packing algorithm to determine how the numbers can be packed into bins of size 45 (3)

A2 October 2020 Q5

EdexcelCurrent spec7 marksAlgorithms

5. The nine distinct numbers in the following list are to be packed into bins of size 50

231719\(x\)248181021

When the first-fit bin packing algorithm is applied to the numbers in the list it results in the following allocation.

Bin 1:23   17   8
Bin 2:19   \(x\)   10
Bin 3:24   18
Bin 4:21
(a) Explain why \(13 \lt x \lt 21\) (3)

The same list of numbers is to be sorted into descending order. A bubble sort, starting at the left-hand end of the list, is to be used to obtain the sorted list. After the first complete pass the list is

23191724\(x\)1810218
(b) Using this information, write down the smallest interval that must contain \(x\), giving your answer as an inequality. (2)

When the first-fit decreasing bin packing algorithm is applied to the nine distinct numbers it results in the following allocation.

Bin 1:24   23
Bin 2:21   19   10
Bin 3:18   17   \(x\)
Bin 4:8

Given that only one of the bins is full and that \(x\) is an integer,

(c) calculate the value of \(x\). You must give reasons for your answer. (2)

AS October 2020 Q1

EdexcelAS paperCurrent spec6 marksAlgorithms

1.

3.72.55.41.92.73.23.12.74.22.0
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 8.5 (3)

The first-fit bin packing algorithm is to be used to pack \(n\) numbers into bins. The number of comparisons is used to measure the order of the first-fit bin packing algorithm.

(b) By considering the worst case, determine the order of the first-fit bin packing algorithm in terms of \(n\). You must make your method and working clear. (3)

AS June 2019 Q2

EdexcelAS paperCurrent spec7 marksAlgorithms

2. The following algorithm produces a numerical approximation for the integral

\[I = \int_{\text{A}}^{\text{B}} x^4 \,\mathrm{d}x\]
Step 1Start
Step 2Input the values of A, B and N
Step 3Let H = (B – A) / N
Step 4Let C = H / 2
Step 5Let D = 0
Step 6Let D = D + A4 + B4
Step 7Let E = A
Step 8Let E = E + H
Step 9If E = B go to Step 12
Step 10Let D = D + 2 × E4
Step 11Go to Step 8
Step 12Let F = C × D
Step 13Output F
Step 14Stop

For the case when A = 1, B = 3 and N = 4,

(a)
(i) complete the table in the answer book to show the results obtained at each step of the algorithm.
(ii) State the final output. (4)

You may not need to use all the rows in this table.
It may not be necessary to complete all boxes in each row.

ABNHCDEF
                                                
                                                
                                                
                                                
                                                
                                                
(b) Calculate, to 3 significant figures, the percentage error between the exact value of \(I\) and the value obtained from using the approximation to \(I\) in this case. (3)

A2 June 2019 Q1

EdexcelCurrent spec8 marksAlgorithms

1.

2.11.73.01.93.21.23.31.41.50.2
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 5 (2)

The list of numbers is now to be sorted into descending order.

(b) Perform a quick sort on the original list to obtain the sorted list. You should show the result of each pass and identify your pivots clearly. (4)

For a list of \(n\) numbers, the quick sort algorithm has, on average, order \(n\log n\).

Given that it takes 2.32 seconds to run the algorithm when \(n = 450\)

(c) calculate approximately how long it will take, to the nearest tenth of a second, to run the algorithm when \(n = 11\,250\). You should make your method and working clear. (2)

AS June 2018 Q1

EdexcelAS paperCurrent spec9 marksAlgorithmsShortest Path

1.

Figure 1: network on vertices A to J with arcs AB 3, AD 25, AI 12, BC 5, CD 14, CE 6, DE 7, EF 8, EG 16, IF 7, IJ 10, FG 9, GH 11, JH 23
Figure 1

Figure 1 represents a network of roads.
The number on each arc represents the time taken, in minutes, to drive along the corresponding road.

(a)
(i) Use Dijkstra’s algorithm to find the shortest time needed to travel from A to H.
(ii) State the quickest route. (6)

For a network with \(n\) vertices, Dijkstra’s algorithm has order \(n^2\)

(b) If it takes 1.5 seconds to run the algorithm when \(n = 250\), calculate approximately how long it will take, in seconds, to run the algorithm when \(n = 9500\). You should make your method and working clear. (2)
(c) Explain why your answer to part (b) is only an approximation. (1)

D1 June 2019 Q4

EdexcelOld spec15 marksAlgorithms

4.

2593216172318124840

The numbers in the list represent the weights, in kilograms, of eleven suitcases. The suitcases are to be transported in containers that will each hold a maximum weight of 50 kg.

(a) Calculate a lower bound for the number of containers needed. You must make your method clear. (2)
(b) Use the first-fit bin packing algorithm to allocate the suitcases to the containers. (2)
(c) Carry out a quick sort to produce a list of the weights in descending order. You should show the result of each pass and identify your pivots clearly. (4)
(d) Use the first-fit decreasing bin packing algorithm to allocate the suitcases to the containers. (3)

The two heaviest suitcases are replaced with two suitcases both of which weigh \(x\) kg. It is given that the lower bound for the number of containers needed is now one less than the number found in (a).

(e) Determine the range of values for \(x\). You should make your working clear. (4)

D1 June 2018 Q2

EdexcelOld spec12 marksAlgorithms

2. A list of nine numbers needs to be sorted into descending order.

(a) Describe how to carry out the first pass of a bubble sort on the numbers in the list. (2)

Mayleen used a sorting algorithm to sort a list of nine numbers into descending order.

Mayleen’s list after the first pass through the algorithm is given below.

30     33     35     27     20     24     21     15     19

(b) Explain how you know that Mayleen did not use the bubble sort algorithm. (2)

Given that Mayleen used the quick sort algorithm,

(c) write down the number that was used as a pivot for the first pass, (1)
(d) complete the quick sort to obtain a fully sorted list in descending order. You must make your pivots clear. (3)
(e) Use the first-fit decreasing bin packing algorithm to determine how the numbers listed can be packed into bins of size 60 (3)

A tenth number, 18, is added to the list of nine numbers.

(f) Determine whether it is possible to pack the ten numbers into 4 bins of size 60.
You must justify your answer. (1)

D1 June 2017 Q3

EdexcelOld spec13 marksAlgorithms

3.

42     21     15     16     35     10     31     11     27     39

(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 65 (3)
(b) The list of numbers is to be sorted into descending order. Use a quick sort to obtain the sorted list. You should show the result of each pass and identify your pivots clearly. (4)
(c) Use the first-fit decreasing bin packing algorithm on your ordered list to pack the numbers into bins of size 65 (3)

The nine distinct numbers below are to be sorted into descending order

23     14     17     \(x\)     21     18     8     20     11

A bubble sort, starting at the left-hand end of the list, is to be used to obtain the sorted list. After the first complete pass, the list is

23     17     \(x\)     21     18     14     20     11     8

After the second complete pass, the list is

23     17     21     18     \(x\)     20     14     11     8

(d) Using this information, write down the smallest interval that must contain \(x\). Give your answer as an inequality. (3)

D1 June 2016 Q5

EdexcelOld spec7 marksAlgorithms

5.

Figure 4: flow chart of the algorithm
Figure 4

An algorithm is described by the flow chart shown in Figure 4.

Given that \(x = 27\) and \(y = 5\),

(a) complete the table in the answer book to show the results obtained at each step when the algorithm is applied. Give the final output. (4)

The numbers 122 and \(\dfrac{1}{2}\) are to be used as inputs for the algorithm described by the flow chart.

(b)
(i) State, giving a reason, which number should be input as \(x\).
(ii) State the output. (3)

D1 June 2016 Q3

EdexcelOld spec9 marksAlgorithms

3.

59   45   18   55   47   11   63   17   15   42

(a) The list of numbers above is to be sorted into descending order. Perform a quick sort to obtain the sorted list. You should show the result of each pass and identify your pivots clearly. (4)

The numbers in the list represent the lengths, in cm, of some pieces of copper wire. The copper wire is sold in one metre lengths.

(b) Use the first-fit decreasing bin packing algorithm to determine how these pieces could be cut from one metre lengths. (You should ignore wastage due to cutting.) (3)
(c) Determine whether your solution to (b) is optimal. Give a reason for your answer. (2)

D1 June 2015 Q2

EdexcelOld spec11 marksAlgorithms

2.

18     29     48     9     42     31     37     24     27     41

The numbers above are Alan’s batting scores for the first 10 cricket matches of the season.

(a) Use a quick sort to sort this list of numbers into ascending order. You must make your pivots clear. (4)

Alan’s batting scores for the final 10 cricket matches of the same season were

72     53     89     91     68     67     90     77     83     75

(b) Carry out a bubble sort on this second list of numbers to produce a list of these scores in ascending order. You need only give the state of the list after each pass. (4)

Alan’s combined batting scores for the entire season were

9   18   24   27   29   31   37   41   42   48   53   67   68   72   75   77   83   89   90   91

(c) Use the binary search algorithm to locate 68 in the combined list of 20 scores. You must make your method clear. (3)

D1 June 2014 (R) Q1

EdexcelOld spec11 marksAlgorithms

1.

31     10     38     45     19     47     35     28     12

(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 60 (3)
(b) Carry out a quick sort to produce a list of the numbers in descending order. You should show the result of each pass and identify your pivots clearly. (4)
(c) Use the first-fit decreasing bin packing algorithm to determine how the numbers listed can be packed into bins of size 60 (2)
(d) Determine whether the number of bins used in (c) is optimal. Give a reason for your answer. (2)

D1 June 2014 Q6

EdexcelOld spec13 marksAlgorithms

6.

24 14 8 \(x\) 19 25 6 17 9

The numbers in the list represent the exact weights, in kilograms, of 9 suitcases. One suitcase is weighed inaccurately and the only information known about the unknown weight, \(x\) kg, of this suitcase is that \(19 \lt x \leqslant 23\). The suitcases are to be transported in containers that can hold a maximum of 50 kilograms.

(a) Use the first-fit bin packing algorithm, on the list provided, to allocate the suitcases to containers. (3)
(b) Using the list provided, carry out a quick sort to produce a list of the weights in descending order. Show the result of each pass and identify your pivots clearly. (4)
(c) Apply the first-fit decreasing bin packing algorithm to the ordered list to determine the 2 possible allocations of suitcases to containers. (4)

After the first-fit decreasing bin packing algorithm has been applied to the ordered list, one of the containers is full.

(d) Calculate the possible integer values of \(x\). You must show your working. (2)

D1 June 2013 (R) Q4

EdexcelOld spec8 marksAlgorithms

4.

1. Sam (S)
2. Janelle (J)
3. Haoyu (H)
4. Alfie (A)
5. Cyrus (C)
6. Komal (K)
7. Polly (P)
8. David (D)
9. Tom (T)
10. Lydia (L)

A binary search is to be performed on the names in the list above to locate the name Lydia.

(a) Using an appropriate algorithm, rearrange the list so that a binary search can be performed, showing the state of the list after each complete iteration. State the name of the algorithm you have used. (4)
(b) Use the binary search algorithm to locate the name Lydia in the list you obtained in (a). You must make your method clear. (4)

D1 June 2013 Q2

EdexcelOld spec11 marksAlgorithms

2.

0.6 1.5 1.6 0.2 0.4 0.5 0.7 0.1 0.9 0.3

(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 2. (3)
(b) The list of numbers is to be sorted into descending order. Use a quick sort to obtain the sorted list. You must make your pivots clear. (4)
(c) Apply the first-fit decreasing bin packing algorithm to your ordered list to pack the numbers into bins of size 2. (3)
(d) Determine whether your answer to (c) uses the minimum number of bins. You must justify your answer. (1)

D1 January 2013 Q2

EdexcelOld spec6 marksAlgorithms

2.

(a) Starting with a list of all the letters of the alphabet in alphabetical order, demonstrate how a binary search is used to locate the letter P. In each iteration, you must make clear your pivot and the part of the list you are retaining. (4)
(b) Find the maximum number of iterations needed to locate any particular letter of the alphabet. Justify your answer. (2)

D1 January 2013 Q1

EdexcelOld spec6 marksAlgorithms

1.

Figure 1: flow chart. Start; Input N and E; R = (N/E + E)/2; Is −10^−6 < R − E < 10^−6? No: E = R and loop back; Yes: Output R; Stop
Figure 1

Hero’s algorithm for finding a square root is described by the flow chart shown in Figure 1.

Given that \(N = 72\) and \(E = 8\),

(a) use the flow chart to complete the table in the answer book, working to at least seven decimal places when necessary. Give the final output correct to seven decimal places. (4)

The flow chart is used with \(N = 72\) and \(E = -8\),

(b) describe how this would affect the output. (1)
(c) State the value of E which cannot be used when using this flow chart. (1)

D1 June 2012 Q1

EdexcelOld spec12 marksAlgorithms

1. A carpet fitter needs the following lengths, in metres, of carpet.

20 33 19 24 31 22 27 18 25

He cuts them from rolls of length 50 m.

(a) Calculate a lower bound for the number of rolls he needs.
You must make your method clear. (2)
(b) Use the first-fit bin packing algorithm to determine how these lengths can be cut from rolls of length 50 m. (3)
(c) Carry out a bubble sort to produce a list of the lengths needed in descending order.
You need only give the state of the list after each pass. (4)
(d) Apply the first-fit decreasing bin packing algorithm to show how these lengths may be cut from the rolls. (3)

D1 January 2012 Q5

EdexcelOld spec13 marksAlgorithms

5.

5181316582151210
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 20. (3)
(b) The list of numbers is to be sorted into descending order. Use a bubble sort to obtain the sorted list, giving the state of the list after each complete pass. (5)
(c) Apply the first-fit decreasing bin packing algorithm to your ordered list to pack the numbers into bins of size 20. (3)
(d) Determine whether your answer to (c) uses the minimum number of bins. You must justify your answer. (2)

D1 June 2011 Q1

EdexcelOld spec9 marksAlgorithms

1.

1.Jenny
2.Merry
3.Charles
4.Ben
5.Toby
6.Hyo
7.Kim
8.Richard
9.Greg
10.Freya

A binary search is to be performed on the names in the list above to locate the name Kim.

(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, showing the state of the list after each complete iteration. State the name of the algorithm you have used. (4)
(c) Use the binary search algorithm to locate the name Kim in the list you obtained in (b). You must make your method clear. (4)

D1 January 2011 Q2

EdexcelOld spec12 marksAlgorithms

2.

23     29     11     34     10     14     35     17

The numbers represent the sizes, in megabytes (MB), of eight files.

The files are to be stored on 50 MB discs.

(a) Calculate a lower bound for the number of discs needed to store all eight files. (2)
(b) Use the first-fit bin packing algorithm to fit the files onto the discs. (3)
(c) Perform a bubble sort on the numbers in the list to sort them into descending order. You need only write down the final result of each pass. (4)
(d) Use the first-fit decreasing bin packing algorithm to fit the files onto the discs. (3)

D1 June 2010 Q3

EdexcelOld spec9 marksAlgorithms

3.

41    28    42    31    36    32    29

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)

D1 June 2010 Q1

EdexcelOld spec8 marksAlgorithms

1.

Hajra
(H)
Vicky
(V)
Leisham
(L)
Alice
(A)
Nicky
(N)
June
(J)
Sharon
(S)
Tom
(T)
Paul
(P)

The table shows the names of nine people.

(a) Use a quick sort to produce the list of names in ascending alphabetical order.
You must make your pivots clear. (4)
(b) Use the binary search algorithm on your list to locate the name Paul. (4)

D1 January 2010 Q5

EdexcelOld spec7 marksAlgorithms

5.

Figure 4: flowchart. Start; Input S; T = 0; R = S – 8000; R > 0? No to Output T; Yes: T = 0.2R; R = R – 10 000; R > 0? No to Output T; Yes: T = T + 0.15R; R = R – 12 000; R > 0? No to Output T; Yes: T = T + 0.1R; Output T; End
Figure 4

An algorithm is described by the flowchart shown in Figure 4.

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

D1 January 2010 Q4

EdexcelOld spec11 marksAlgorithms

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

Guttering is sold in 4 m lengths.

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

D1 June 2009 Q4

EdexcelOld spec9 marksAlgorithms

4.

MiriJessieEdwardKatieHeggBethLouisPhilipNatsukoDylan
(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)

D1 June 2009 Q2

EdexcelOld spec9 marksAlgorithms

2.

3245172338281691210

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.

(a) Calculate a lower bound for the number of rolls needed. (2)
(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)

D1 January 2009 Q1

EdexcelOld spec9 marksAlgorithms

1.

MaxLaurenJohnHannahKieranTaraRichardImogen
(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)

D1 June 2008 Q1

EdexcelOld spec8 marksAlgorithms

1.

295273877447386141

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)

D1 January 2008 Q2

EdexcelOld spec10 marksAlgorithmsMinimum Spanning Trees

2.

(a)
18201171715142123169

The list of numbers shown above is to be sorted into ascending order. Apply quick sort to obtain the sorted list. You must make your pivots clear. (5)

Figure 3: network of paths with vertices A to I and arc lengths in metres
Figure 3

Figure 3 represents a network of paths in a park. The number on each arc represents the length of the path in metres.

(b) Using your answer to part (a) and Kruskal’s algorithm, find a minimum spanning tree for the network in Figure 3. You should list the arcs in the order in which you consider them and state whether you are adding it to your minimum spanning tree. (4)
(c) Find the total weight of the minimum spanning tree. (1)

D1 June 2007 Q3

EdexcelOld spec9 marksAlgorithms

3. An algorithm is described by the flow chart shown in Figure 3.

Figure 3: flow chart. Let A = 0, input x, y; if x even, x = x / 2 and y = 2y and repeat; if x odd, A = A + y, x = x - 1, then if x = 0 output A and stop, else x = x / 2, y = 2y
Figure 3
(a) Given that \(x = 54\) and \(y = 63\), complete the table in the answer book to show the results obtained at each step when the algorithm is applied. (7)
(b) State what the algorithm achieves. (2)

D1 January 2007 Q1

EdexcelOld spec4 marksAlgorithms

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

1.  Bhavika
2.  Clive
3.  Elizabeth
4.  John
5.  Mark
6.  Nicky
7.  Preety
8.  Steve
9.  Trevor
10.  Verity

D1 June 2006 Q1

EdexcelOld spec4 marksAlgorithms

1.

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

D1 January 2006 Q3

EdexcelOld spec9 marksAlgorithms

3.

Figure 3: flow chart. Start; let n = 0, A = (1 + root 5) / 2 and B = (1 - root 5) / 2 to 3 d.p.; let n = n + 1; let C = A^n, D = B^n to 3 d.p.; let E = (C - D) / root 5 to 1 s.f.; output E; is n > 4? No: back to let n = n + 1; Yes: stop
Figure 3

An algorithm is described by the flow chart shown in Figure 3.

(a) Complete the table in the answer book 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.)
\(A\)\(B\)\(n\)\(C\)\(D\)\(E\)
      
      
      
      
      
(8)
(b) Write down the output from the algorithm. (1)

D1 June 2005 Q1

EdexcelOld spec5 marksAlgorithms

1.

Ali74
Bobby28
Eun-Jung63
Katie54
Marciana54
Peter49
Rory37
Sophie68

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

D1 January 2005 Q4

EdexcelOld spec11 marksAlgorithms

4.

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)