D1: Algorithms (sorting, searching, bin packing) – Edexcel IAL Decision Mathematics (WDM1)
12 questions · Clear filters
Question text
1. In the following list, eleven sports are identified by their initial letter
(V) Volleyball
(H) Handball
(W) Wheelchair basketball
(B) Baseball
(R) Rugby
(G) Golf
(C) Cricket
(P) Paratriathlon
(T) Tennis
(D) Diving
(S) Squash
(a) Explain why a binary search cannot be performed on this list in its current form.
(1)
(b) Write the list in an appropriate form and show how a binary search is used to try to
locate (F) Football. You must make your choice of pivots clear.
(4)
(Total for Question 1 is 5 marks)
Question text
4. The following list of eleven distinct integers is to be sorted into ascending order.
44
35
73
24
58
32
21
61
54
31
x
The first two passes of bubble sort are
35
44
24
58
32
21
61
54
31
73
x
35
44
24
32
21
58
54
31
61
73
x
(a) Explain why x must satisfy the inequality 45 x 57
(2)
(b) Carry out one more pass of bubble sort, showing the result at the end of the pass.
(2)
Given that
•
when the numbers are placed in bins of size 120, the lower bound for the number of
bins required is five
•
when the first‑fit decreasing algorithm is used to place the numbers in bins of size
160, x is placed in the second bin, which also contains 54
(c) determine the value of x. You must make your reasoning clear.
(3)
(Total for Question 4 is 7 marks)
Question text
6.
A
B
C
D
E
F
G
H
A
‑
24
19
28
25
32
29
31
B
24
‑
22
31
25
23
37
41
C
19
22
‑
18
21
41
31
35
D
28
31
18
‑
24
21
27
26
E
25
25
21
24
‑
17
31
25
F
32
23
41
21
17
‑
26
31
G
29
37
31
27
31
26
‑
24
H
31
41
35
26
25
31
24
‑
The table shows the least distances, in km, between eight towns. Imani wants to visit all
eight towns. She needs to find a route which minimises the distance travelled, starting
and finishing at A.
(a) Show that there are two nearest neighbour routes starting at A. You must make your
method clear and state the routes and their lengths.
(4)
(b) State, giving a reason, which route from part (a) gives the better upper bound for the
length of Imani’s route.
(1)
(c) By deleting A and all of its arcs, use Prim’s algorithm, starting at B, to obtain a
lower bound for the length of Imani’s route. You must show your working.
(4)
A second lower bound of 172 km is obtained by deleting H.
(d) Write down the smallest interval that must contain the optimal length for
Imani’s route.
(1)
(Total for Question 6 is 10 marks)
Question text
1.
5.0 1.8 6.2 2.8 3.0 4.0 3.8 2.4 0.6 0.8 7.8
The numbers in the list are the lengths, in feet, of eleven pieces of wood. They are to be
cut from planks of wood of length 10 feet. You should ignore wastage due to cutting.
(a) Calculate a lower bound for the number of planks needed. You must make your
method clear.
(2)
(b) Use the first-fit bin packing algorithm to determine how these pieces could be cut
from 10 feet planks.
(3)
(c) Carry out a quick sort to produce a list of the lengths 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 determine how these pieces
could be cut from 10 feet planks.
(2)
(Total for Question 1 is 11 marks)
Question text
1. The following list of eleven numbers is to be packed into bins of size 55
26
19
31
10
14
30
33
18
3
28
5
(a) Use the first‑fit bin packing algorithm to pack the numbers into bins of size 55
(3)
(b) Use quick sort to sort the list into descending order, showing the result after each
pass. You must clearly identify the pivots used.
(4)
(c) Apply the first‑fit decreasing bin packing algorithm to pack the numbers into bins
of size 55
(2)
(Total for Question 1 is 9 marks)
Question text
3.
Start
Input a, b
Let c = ab
a
Let d = a
b
Let e = INT(d)
Let f = be
Let g = a – f
Yes
c
Is
Let h = c
g = 0?
b
No
Output h
Let a = b
Stop
Let b = g
Figure 2
Figure 2 shows the flowchart for an algorithm.
The input for the algorithm is two positive integers.
The function INT(X) is the largest integer less than or equal to X
(a) Complete the table in the answer book, with a = 1980 and b = 462, showing the
results at each step of the algorithm.
(4)
(b) Explain how the output, h, relates to the inputs, a and b
(1)
(Total for Question 3 is 5 marks)
Question text
3. You may not need all the rows in this table.
a
b
c
d
e
f
g
h
Output
(Total for Question 3 is 5 marks)
Question text
6. The twelve numbers in the list below are to be packed into bins of size n, where n is a
positive integer.
28
31
5
25
16
35
18
22
11
27
15
13
When the first‑fit bin packing algorithm is applied to the list, the following allocation
is obtained.
Bin 1:
28
31
5
Bin 2:
25
16
18
11
Bin 3:
35
22
15
Bin 4:
27
13
(a) Based on the packing shown above, determine the possible values of n. You must
give reasons for your answer.
(3)
(b) The original list of twelve numbers is to be sorted into ascending order. Use a quick
sort to obtain the sorted list. 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, the following
allocation is obtained.
Bin 1:
35
31
5
Bin 2:
28
27
16
Bin 3:
25
22
18
Bin 4:
15
13
11
(c) Determine the value of n. You must give a reason for your answer.
(2)
(Total for Question 6 is 9 marks)
Question text
1.
A
B
C
D
E
F
G
A
–
43
52
47
59
53
55
B
43
–
59
45
46
52
47
C
52
59
–
51
50
55
51
D
47
45
51
–
52
49
55
E
59
46
50
52
–
57
48
F
53
52
55
49
57
–
55
G
55
47
51
55
48
55
–
The table above shows the least distances, in metres, between seven classrooms, A, B,
C, D, E, F and G. A teacher needs to visit each classroom, starting and finishing at A,
and wishes to minimise the total distance travelled.
(a) Show that there are two nearest neighbour routes that start from A. State these routes
and their corresponding lengths.
(3)
(b) Starting by deleting A, and all of its arcs, find a lower bound for the length of the
teacher’s route.
(3)
(c) Use your results to write down the smallest interval which you can be confident
contains the optimal length of the teacher’s route.
(1)
(Total for Question 1 is 7 marks)
Question text
3.
1.8 1.4 2.6 1.6 2.8 0.9 3.1 0.8 1.2 2.4 0.6
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above
can be packed into bins of size 5
(3)
The list is to be sorted into descending order.
(b) (i) Perform one pass of a bubble sort, starting at the left-hand end of the list. You
must write down the list that results at the end of the first pass.
(ii) Write down the number of comparisons and the number of swaps performed
during the first pass.
(3)
After a second pass using this bubble sort, the updated list is
2.6 1.8 2.8 1.6 3.1 1.4 1.2 2.4 0.9 0.8 0.6
(c) Use a quick sort on this updated list to obtain the fully sorted list in descending
order. You must make your pivots clear.
(4)
(d) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack
the numbers into bins of size 5
(3)
(Total for Question 3 is 13 marks)
Question text
2.
A restaurant sells two sizes of pizza, small and large. The restaurant owner knows that, each
evening, she needs to make
•
at least 85 pizzas in total
•
at least twice as many large pizzas as small pizzas
In addition, at most 80% of the pizzas must be large.
Each small pizza costs £2 to make and each large pizza costs £3 to make.
The restaurant owner wants to minimise her costs.
Let x represent the number of small pizzas made each evening and let y represent the number of
large pizzas made each evening.
Formulate the information above as a linear programming problem. State the objective and list the
constraints as simplified inequalities with integer coefficients. You should not attempt to solve the
problem.
(Total 5 marks)
3.
2.6 0.8 2.1 1.2 0.9 1.7 2.3 0.3 1.8 2.7
(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be
packed into bins of size 5
(3)
The list is to be sorted into descending order.
(b) (i) Starting at the left-hand end of the above list, perform two passes through the list using a
bubble sort. Write down the lists that result at the end of the first pass and the second pass.
(ii) Write down, in the table in the answer book, the number of comparisons and the number
of swaps performed during each of these two passes.
(4)
After a third pass using this bubble sort, the updated list is
2.6 2.1 1.7 2.3 1.2 1.8 2.7 0.9 0.8 0.3
(c) Use a quick sort on this updated list to obtain the fully sorted list. You must make your
pivots clear.
(3)
(d) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack the numbers
into bins of size 5
(3)
(Total 13 marks)
4.
(a) Explain the difference between the classical and the practical travelling salesperson problems.
(2)
The table below shows the distances, in km, between seven museums, A, B, C, D, E, F and G.
A
B
C
D
E
F
G
A
–
25
31
28
35
30
32
B
25
–
34
24
27
32
39
C
31
34
–
40
35
27
29
D
28
24
40
–
37
35
36
E
35
27
35
37
–
28
31
F
30
32
27
35
28
–
33
G
32
39
29
36
31
33
–
Fran must visit each museum. She will start and finish at A and wishes to minimise the total
distance travelled.
(b) Starting at A, use the nearest neighbour algorithm to obtain an upper bound for the length of
Fran’s route. Make your method clear.
(2)
Starting at D, a second upper bound of 203 km was found.
(c) State whether this is a better upper bound than the answer to (b), giving a reason for your
answer.
(1)
A reduced network is formed by deleting G and all the arcs that are directly joined to G.
(d) (i) Use Prim’s algorithm, starting at A, to construct a minimum spanning tree for the reduced
network. You must clearly state the order in which you select the arcs of your tree.
(ii) Hence calculate a lower bound for the length of Fran’s route.
(4)
By deleting A, a second lower bound was found to be 188 km.
(e) State whether this is a better lower bound than the answer to (d)(ii), giving a reason for
your answer.
(1)
(f) Using only the results from (c) and (e), write down the smallest interval that you can be
confident contains the length of Fran’s optimal route.
(2)
(Total 12 marks)
5.
B
D
G
22
12
13
32
10
7
A
9
22
E
15
J
16
C
5
28
5
F
22
29
H
K
6
Figure 1
[The total weight of the network is 253]
Figure 1 represents a network of roads between 10 cities, A, B, C, D, E, F, G, H, J and K.
The number on each edge represents the length, in miles, of the corresponding road.
One day, Mabintou wishes to travel from A to H. She wishes to minimise the distance she travels.
(a) Use Dijkstra’s algorithm to find the shortest path from A to H. State your path and its length.
(6)
On another day, Mabintou wishes to travel from F to K via A.
(b) Find a route of minimum length from F to K via A and state its length.
(2)
The roads between the cities need to be inspected. James must travel along each road at least once.
He wishes to minimise the length of his inspection route. James will start his inspection route at A
and finish at J.
(c) By considering the pai
Question text
1.
Use the binary search algorithm to try to locate the name Hilbert in the following alphabetical list.
Clearly indicate how you chose your pivots and which part of the list is being rejected at each stage.
Descartes
Euler
Gauss
Hamilton
Lagrange
Noether
Poisson
Ramanujan
Stokes
Turing
(Total 4 marks)
2.
A
B
C
D
E
F
G
H
A
–
27
51
32
29
23
47
40
B
27
–
24
35
20
42
33
28
C
51
24
–
37
43
31
26
34
D
32
35
37
–
39
45
44
30
E
29
20
43
39
–
38
45
55
F
23
42
31
45
38
–
53
45
G
47
33
26
44
45
53
–
39
H
40
28
34
30
55
45
39
–
The table represents a network that shows the average journey time, in minutes, between eight
towns, A, B, C, D, E, F, G and H.
(a) Use Prim’s algorithm, starting at A, to find the minimum spanning tree for this network. You
must clearly state the order in which you select the edges of your tree.
(3)
(b) Draw the minimum spanning tree using the vertices given in Diagram 1 in the answer book.
(1)
(c) State the weight of the minimum spanning tree.
(1)
(Total 5 marks)
3.
A
1
A
1
B
2
B
2
C
3
C
3
4
4
D
D
E
E
5
5
F
6
F
6
Figure 1
Figure 2
Figure 1 shows the possible allocations of six workers, A, B, C, D, E and F, to six tasks, 1, 2, 3,
4, 5 and 6. Each task must be assigned to only one worker and each worker must be assigned to
exactly one task.
Figure 2 shows an initial matching.
(a) Starting from the given initial matching, use the maximum matching algorithm to find an
alternating path from A to 4. Hence find an improved matching. You should list the alternating
path you use, and state your improved matching.
(3)
(b) Explain why it is not possible to find a complete matching.
(1)
After training, task 1 is added to worker A’s possible allocations.
(c) Starting from the improved matching found in (a), use the maximum matching algorithm to
find a complete matching. You should list the alternating path you use, and state your complete
matching.
(3)
(Total 7 marks)
4.
23
18
27
9
25
10
12
30
24
The numbers in the list represent the weights, in kilograms, of nine suitcases. The suitcases are to
be transported in containers that will each hold a maximum weight of 45 kilograms.
(a) Calculate a lower bound for the number of containers that will be needed to transport the
suitcases.
(2)
(b) Use the first-fit bin packing algorithm to allocate the suitcases to the containers.
(2)
(c) Using the list provided, carry out a bubble sort to produce a list of the weights in descending
order. You need only give the state of the list after each complete pass.
(4)
(d) Use the first-fit decreasing bin packing algorithm to allocate the suitcases to the containers.
(2)
(e) Explain why it is not possible to transport the suitcases using fewer containers than the number
used in (d).
(1)
(Total 11 marks)
5.
B
C
13.2
8.9
2.4
A
D
11.5
5.3
6.5
5.5
F
2.7
E
G
4.9
10.2
1.2
12.5
J
3.1
1.9
I
H
6.4
10.5
K
Figure 3
[The total weight of the network is 106.7]
Figure 3 models a network of cycle tracks that have to be inspected. The number on each arc
represents the length, in km, of the corresponding track. Angela needs to travel along each cycle
track at least once and wishes to minimise the length of her inspection route. She must start and
finish at A.
(a) Use an appropriate algorithm to find the tracks that will need to be traversed twice. You should
make your method and working clear.
(5)
(b) Find a route of minimum length, starting and finishing at A. State the length of your route.
(2)
A new cycle track, AC, is under construction. It will be 15 km long. Angela will have to include
this new track in her inspection route.
(c) State the effect this new track will have on the total length of her route. Justify your answer.
(2)
(Total 9 marks)
6.
A
14
D
8
4
21
8
25
B
10
5
E
C
2x
4
H
17
12
F
4
9
x
6
G
Figure 4
Figure 4 represents a network of roads. The number on each arc represents the time taken, in
minutes, to drive along the corresponding road.
Stieg wishes to minimise the time spent driving from his home at A, to his office at H. The amount
of traffic