D1-HW-Booklet-Students-Copy
D1-HW-Booklet-Students-Copy
Name
Teacher
Grid
Contents Marks %
1. Algorithms ................................................................ 2
2. Prim’s and Kruskal’s ................................................ 11
3. Dijkstra’s Algorithm ................................................ 24
4. Route Inspection..................................................... 35
5. Critical Path Analysis............................................... 45
6. Linear Programming ............................................... 54
7. Matching’s .............................................................. 67
Munem Ahmed
1
1. Algorithms
2
1.
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)
3
4
2. 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)
5
6
3. Miri, Jessie, Edward, Katie, Hegg, Beth, Louis, Philip, Natsuko, Dylan
(a) Use the quick sort algorithm to sort the list above into alphabetical order.
(5)
(b) Use the binary search algorithm to locate the name Louis.
(4)
7
8
4.
A x y x even? x=0?
to show the results obtained at each step when the algorithm is applied.
(7)
(b) State what the algorithm achieves.
(2)
9
10
2. Prim’s and Kruskal’s
11
Q1.
Figure 1
(a) Use Kruskal's algorithm to find the minimum spanning tree for the network. You should list the
arcs in the order in which you consider them. In each case, state whether you are adding the arc to
your minimum spanning tree.
(3)
(b) Starting at A, use Prim's algorithm to find the minimum spanning tree. You must clearly state the
order in which you
selected the arcs of your tree.
(3)
(c) Draw the minimum spanning tree using the vertices given in Diagram 1 in the answer book.
(1)
(d) State the weight of the tree.
(1)
(Total 8 marks)
12
13
14
Q2.
The table shows the lengths, in km, of a network of roads between seven villages, A, B, C, D, E, F and
G.
(a) Complete the drawing of the network in Diagram 1 of the answer book by adding the necessary
arcs from vertex D together with their weights.
(2)
(b) Use Kruskal's algorithm to find a minimum spanning tree for the network. You should list the
arcs in the order that you consider them. In each case, state whether you are adding the arc to your
minimum spanning tree.
(3)
(c) Draw the minimum spanning tree using the vertices provided in Diagram 2 in the answer book.
(1)
(d) State the weight of the minimum spanning tree.
(1)
(Total 7 marks)
15
16
17
Q3.
18
19
20
Q4.
The table shows the distances, in metres, between six vertices, A, B, C, D, E and F, in a network.
(a) Draw the weighted network using the vertices given in Diagram 1 in the answer booklet.
(3)
(b) Use Kruskal's algorithm to find a minimum spanning tree. You should list the edges in the order
that you consider them and state whether you are adding them to your minimum spanning tree.
(3)
(c) Draw your tree on Diagram 2 in the answer booklet and find its total weight.
(2)
(Total 8 marks)
21
22
23
3. Dijkstra’s Algorithm
24
Q1.
Figure 5
Figure 5 models a network of roads. The number on each edge gives the time, in minutes, taken to
travel along that road. Olivia wishes to travel from A to J as quickly as possible.
(a) Use Dijkstra's algorithm to find the shortest time needed to travel from A to J. State the shortest
route.
(7)
On a particular day Olivia must include G in her route.
(b) Find a route of minimal time from A to J that includes G, and state its length
(2)
(Total 9 marks)
25
26
27
Q2.
Figure 4 shows a network of roads. The number on each arc represents the length, in miles, of the
corresponding road.
(a) Use Dijkstra's algorithm to find the shortest route from S to T. State your shortest route and its
length.
(6)
(b) Explain how you determined your shortest route from your labelled diagram.
(2)
Due to flooding, the roads in and out of D are closed.
(c) Find the shortest route from S to T avoiding D. State your shortest route and its length.
(2)
(Total 10 marks)
28
29
30
Q3.
Figure 6 shows a network of cycle tracks. The number on each arc gives the length, in km, of that
track.
(a) Use Dijkstra's algorithm to find the shortest route from A to H. State your shortest route and its
length.
(6)
(b) Explain how you determined your shortest route from your labelled diagram.
(2)
The track between E and F is now closed for resurfacing and cannot be used.
(c) Find the shortest route from A to H and state its length.
(2)
(Total 10 marks)
31
32
Shortest Route
Length of Shortest Route
33
34
4. Route Inspection
35
Q1.
Figure 2
Figure 2 models a network of canals. The number on each arc gives the length, in miles, of that
canal.
Brett needs to travel along each canal to check that it is in good repair. He wishes to minimise the
length of his route.
(a) Use the route inspection algorithm to find the length of his route. State the arcs that should be
repeated. You should
make your method and working clear.
(6)
A canal between B and F, of length 12 miles, is to be opened and needs to be included in Brett's
inspection route.
(b) Determine if the addition of this canal will increase or decrease the length of Brett's minimum
route. You must make
your reasoning clear.
(2)
(Total 8 marks)
36
37
38
Q2.
(b) Use the route inspection algorithm to find the pipes that will need to be traversed twice. You
should make your method and working clear.
(5)
(c) Find the length of the inspection route.
(1)
Pipe HI is now found to be blocked; it is sealed and will not be replaced. An inspection route is now
required that excludes pipe HI. The length of the inspection route must be minimised.
(d) Find the length of the minimum inspection route excluding HI. Justify your answer.
(2)
(e) Given that the device may now start at any vertex and finish at any vertex, find a minimum
inspection route, excluding HI.
(2)
39
(Total 12 marks)
40
41
Q3.
Figure 5 models a network of gas pipes that have to be inspected. The number on each arc
represents the length, in km, of that pipe.
A route of minimum length that traverses each pipe at least once and starts and finishes at A needs
to be found.
(a) Use the route inspection algorithm to find the pipes that will need to be traversed twice. You
must make your method and working clear.
(5)
(b) Write down a possible shortest inspection route, giving its length.
(2)
It is now decided to start the inspection route at D. The route must still traverse each pipe at least
once but may finish at any node.
(c) Determine the finishing point so that the length of the route is minimised. You must give reasons
for your answer and state the length of your route.
(3)
(Total 10 marks)
42
43
44
5. Critical Path Analysis
45
Q1.
(a) Draw the activity network described in this precedence table, using activity on arc and exactly
two dummies.
(5)
46
47
Q2.
Figure 7
A project is modelled by the activity network shown in Figure 7. The activities are represented by the
arcs. The number in brackets on each arc gives the time required, in hours, to complete the activity.
The numbers in circles are the event numbers. Each activity requires one worker.
(a) Explain the significance of the dummy activity
(i) from event 4 to event 6,
(ii) from event 5 to event 7
(3)
(b) Calculate the early time and the late time for each event. Write these in the boxes in the answer
book.
(4)
(c) Calculate the total float on each of activities D and G. You must make the numbers you use in
your calculations clear.
(3)
(d) Calculate a lower bound for the minimum number of workers required to complete the project in
the minimum time.
(2)
(e) On the grid in your answer book, draw a cascade (Gantt) chart for this project.
(4)
(Total 16 marks)
48
49
50
Q3.
Figure 5 is the activity network relating to a development project. The activities are represented by
the arcs. The number in brackets on each arc gives the time, in days, to complete the activity. Each
activity requires one worker. The project is to be completed in the shortest possible time.
51
52
53
6. Linear Programming
54
Q1.
A manufacturer of frozen yoghurt is going to exhibit at a trade fair. He will take two types of frozen
yoghurt, Banana Blast and Strawberry Scream.
He will take a total of at least 1000 litres of yoghurt.
He wants at least 25% of the yoghurt to be Banana Blast. He also wants there to be at most half as
much Banana Blast as Strawberry Scream.
Each litre of Banana Blast costs £3 to produce and each litre of Strawberry Scream costs £2 to
produce. The manufacturer wants to minimise his costs.
Let x represent the number of litres of Banana Blast and y represent the number of litres of
Strawberry Scream.
Formulate this as a linear programming problem, stating the objective and listing the constraints as
simplified inequalities with integer coefficients.
You should not attempt to solve the problem.
(Total 6 marks)
55
56
Q2.
57
58
Q3.
Figure 6
59
A company is going to hire out two types of car, standard and luxury.
Let x be the number of standard cars it should buy. Let y be the number of luxury cars it should buy.
Figure 6 shows three constraints, other than x, y ≥ 0 Two of these are x ≥ 20 and y ≥ 8
Each time the cars are hired they need to be prepared. It takes 5 hours to prepare a standard car and
it takes 6 hours to prepare a luxury car. There are 300 hours available each week to prepare the cars.
The company expects to make £80 profit per week on each car. It therefore wishes to maximise P =
80x + 80y, where P is the profit per week.
(f) Use the objective line (ruler) method to find the optimal vertex, V, of the feasible region. You
must clearly draw and label your objective line and the vertex V.
(3)
(g) Given that P is the expected profit, in pounds, per week, find the number of each type of car that
the company should buy and the maximum expected profit.
(3)
(Total 13 marks)
60
61
62
63
Q4.
64
65
66
7. Matching’s
67
Q1.
(Total 10 marks)
68
69
70
Q2.
Figure 3 shows the possible allocations of six people, Amelia, Charlie, Ellie, Gemma, Jimmy and
Saskia, to six tasks, 1, 2, 3, 4, 5 and 6.
Figure 4 shows an initial matching.
(a) Use the maximum matching algorithm once to find an improved matching.
You must state the alternating path used and your improved matching.
(3)
(b) Explain why a complete matching is not possible.
(2)
After training, Jimmy can be assigned to tasks 4 or 5 and Ellie to tasks 2, 3, 5 or 6.
(c) Starting with your current maximal matching, use the maximum matching algorithm to obtain a
complete matching. You must state the alternating path used and your final matching.
(3)
(Total 8 marks)
71
72
73
Q3.
Six pupils, Ashley (A), Fran (F), Jas (J), Ned (N), Peter (P) and Richard (R), each wish to learn a musical
instrument. The school they attend has six spare instruments; a clarinet (C), a trumpet (T), a violin
(V), a keyboard (K), a set of drums (D) and a guitar (G). The pupils are asked which instruments they
would prefer and their preferences are given in the table above. It is decided that each pupil must
learn a different instrument and each pupil needs to be allocated to exactly one of their preferred
instruments.
(a) Using Diagram 1 in the answer book, draw a bipartite graph to show the possible allocations of
pupils to instruments.
(1)
Initially Ashley, Fran, Jas and Richard are each allocated to their first preference.
(b) Show this initial matching on Diagram 2 in the answer book.
(1)
(c) Starting with the initial matching from (b), apply the maximum matching algorithm once to find
an improved matching. You must state the alternating path you use and give your improved
matching.
(3)
(d) Explain why a complete matching is not possible.
(1)
Fran decides that as a third preference she would like to learn to play the guitar. Peter decides that
as a second preference he would like to learn to play the drums.
(e) Starting with the improved matching found in (c), use the maximum matching algorithm to
obtain a complete matching. You must state the alternating path you use and your complete
matching.
(3)
74
(Total 9 marks)
75
76