D1: Algorithms (sorting, searching, bin packing) – Edexcel IAL Decision Mathematics (WDM1)

26 questions · page 2 of 2

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
16
WDM1 D1 · Jan 2024 · Section 1, Question 6January 2024D19 marks
Loading question…
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)

17
WDM1 D1 · Jun 2023 · Section 1, Question 2May/June 2023D16 marks
Loading question…
Question text

2. A list of eleven numbers is to be sorted into descending order.
After one pass, the quick sort algorithm produces the following list
17 33 14 25 23 28 21 13 9 6 10
(a) State, with a reason, which number was used as a pivot for the first pass.
(1)
(b) Starting at the left-hand end of the above list, obtain the fully sorted list using a
bubble sort. You need to write down only the list that results at the end of each pass.
(3)
(c) Apply the first-fit decreasing bin packing algorithm to the fully sorted list to pack
the numbers into bins of size 85
(2)
(Total for Question 2 is 6 marks)

18
WDM1 D1 · Jun 2023 · Section 1, Question 3May/June 2023D16 marks
Loading question…
Question text

3. In this question, the function INT(X ) is the largest integer less than or equal to X.
For example,
INT(5.7) = 5
INT(8) = 8
INT(–2.3) = –3
Consider the following algorithm.
Step 1 Input N
Step 2
Calculate A = N ÷ 10
Step 3
Let B = INT(A)
Step 4
Calculate C = B × 10
Step 5
Calculate D = N – C
ptep 6&&lutput a
Step 7 Replace N by B
Step 8 If N = 0 then STOP, otherwise go back to Step 2
(a) Complete the table in the answer book, using N = 4217, to show the results obtained
at each step of the algorithm.
(4)
(b) Explain how the output values of the algorithm relate to the original input N,
where N is any positive integer.
(2)
(Total for Question 3 is 6 marks)

Advertisement
19
WDM1 D1 · Jun 2023 · Section 2, Question 3May/June 2023D16 marks
Loading question…
Question text

3.
You may not need to use all the rows in this table.
It may not be necessary to complete all boxes in each row.
N
A
B
C
D
Outputs:
Question 3 continued
(Total for Question 3 is 6 marks)

20
WDM1 D1 · Jan 2023 · Section 2, Question 1January 2023D17 marks
Loading question…
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)

21
WDM1 D1 · Jan 2023 · Section 2, Question 3January 2023D113 marks
Loading question…
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)

22
WDM1 D1 · Jun 2022 · Section 1, Question 1May/June 2022D19 marks
Loading question…
Question text

1.
175
135
210
105
100
150
60
20
70
125
The numbers in the list above represent the weights, in kilograms, of ten crates. The
crates are to be transported in trucks that can each hold a maximum total crate weight
of 300 kg.
(a) Calculate a lower bound for the number of trucks that will be needed to transport
the crates.
(2)
(b) 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 pass.
(4)
(c) Use the first‑fit decreasing bin packing algorithm to allocate the crates to the trucks.
(3)
(Total for Question 1 is 9 marks)

23
WDM1 D1 · Jan 2021 · Question 2January 2021D166 marks
Loading question…
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

Advertisement
24
WDM1 D1 · Oct/Nov 2020 · Question 2Oct/Nov 2020D127 marks
Loading question…
Question text

2.
(a) (i) Describe how to carry out the first pass of a bubble sort when it is used to sort a list of n
numbers into ascending order.
(ii) Write down the circumstances under which the bubble sort stops.
(4)
A bubble sort, starting at the left-hand end of the list, is used to sort a list of ten numbers into
ascending order. After a number of passes the list reads
0.9 1.2 1.5 0.5 1.4 1.1 0.7 1.7 2.2 3.2
(b) Determine the maximum number of passes that could have taken place on this list. You must
give a reason for your answer.
(2)
(c) Complete the bubble sort to produce a list of the numbers in ascending order. You only need to
give the state of the list after each complete pass.
(4)
(d) Use the first-fit decreasing bin packing algorithm to determine how the ten numbers listed
above can be packed into bins of size 4
(3)
(Total 13 marks)
3.
1
A
A
1
2
B
B
2
3
C
C
3
4
D
D
4
5
E
E
5
6
F
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.
Figure 2 shows an initial matching.
(a) Starting from this initial matching, use the maximum matching algorithm to find an improved
matching. You should state the alternating path you use and list 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) Taking the improved matching found in (a) as the new initial matching, use the maximum
matching algorithm to find a complete matching. You should state the alternating path you use
and list your complete matching.
(3)
(Total 7 marks)
4.
(a) Draw the activity network described by the precedence table below, using activity on arc.
Use dummies only where necessary.
(5)
Activity
Immediately preceding activities
A
–
B
–
C
A
D
A, B
E
C, D
F
D
G
C
H
G
I
G
J
E, F, I
K
F
Given that K is a critical activity,
(b) state which other activities must also be critical.
(1)
Given instead that all activities shown in the precedence table have the same duration and K is not
necessarily critical,
(c) state the critical path for the network.
(1)
(Total 7 marks)

25
WDM1 D1 · Oct/Nov 2020 · Question 2Oct/Nov 2020D113 marks
Loading question…
Question text

2.
(a) (i) Describe how to carry out the first pass of a bubble sort when it is used to sort a list of
n numbers into ascending order.
(ii) Write down the circumstances under which a bubble sort stops.
(4)
A bubble sort, starting at the left-hand end of the list, is used to sort a list of ten numbers into
ascending order. After a number of passes the list reads
0.9 1.2 1.5 0.5 1.4 1.1 0.7 1.7 2.2 3.2
(b) Determine the maximum number of passes that could have taken place on this list. You must
give a reason for your answer.
(2)
(c) Complete the bubble sort to produce a list of the numbers in ascending order. You only need to
give the state of the list after each complete pass.
(4)
(d) Use the first-fit decreasing bin packing algorithm to determine how the ten numbers listed
above can be packed into bins of size 4
(3)
(Total 13 marks)

26
WDM1 D1 · Jan 2017 · Question 1January 2017D171 marks
Loading question…
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

Advertisement