0% found this document useful (0 votes)
73 views9 pages

D1 Algorithms - Bin Packing

The document describes several problems involving bin packing algorithms. It provides lists of numbers representing weights, lengths, or durations that must be packed into bins or cut from rolls/rods of a maximum size. For each problem it asks the reader to: 1) Calculate a lower bound for the number of bins/rolls needed 2) Apply the first-fit bin packing algorithm 3) Sometimes apply another algorithm like full bins or first-fit decreasing to optimally solve the problem. The reader must show the results of applying the algorithms and determine if their solutions are optimal using the minimum number of bins/rolls.

Uploaded by

Armaan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views9 pages

D1 Algorithms - Bin Packing

The document describes several problems involving bin packing algorithms. It provides lists of numbers representing weights, lengths, or durations that must be packed into bins or cut from rolls/rods of a maximum size. For each problem it asks the reader to: 1) Calculate a lower bound for the number of bins/rolls needed 2) Apply the first-fit bin packing algorithm 3) Sometimes apply another algorithm like full bins or first-fit decreasing to optimally solve the problem. The reader must show the results of applying the algorithms and determine if their solutions are optimal using the minimum number of bins/rolls.

Uploaded by

Armaan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

D1 Algorithms - Bin packing PhysicsAndMathsTutor.

com

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)
(Total 9 marks)

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

(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)
(Total 9 marks)

Edexcel Internal Review 1


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

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

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)
(Total 11 marks)

Edexcel Internal Review 2


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

5. Nine pieces of wood are required to build a small cabinet. The lengths, in cm, of the pieces of
wood are listed below.

20, 20, 20, 35, 40, 50, 60, 70, 75

Planks, one metre in length, can be purchased at a cost of £3 each.

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

6. 25 22 30 18 29 21 27 21

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

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

Edexcel Internal Review 3


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

239
1. (a) e.g. total weight is 239, lower bound is = 3.98 so 4 bins. M1 A1 2
60
Note
1M1: Any correct statement, must involve calculation
1A1: cao (accept 4 for both marks)

(b) Bin 1 : 41 Bin 4 : 36 M1 A1


Bin 2 : 28 + 31 Bin 5 : 32 A1 3
Bin 3 : 42 Bin 6 : 29
Note
1M1: Bins 1 and 2 correct and at least 6 values put in bins
1A1: Bins 1, 2, 3 and 4 correct.
2A1: All correct
Misread in (b) First Fit Decreasing
Bin 1: 42 Bin 2: 41 Bin 3: 36 Bin 4: 32 28 Bin 5: 31 29
(Remove up to two A marks if earned – so M1 max in (b) if first 4
bins correct.)

(c) Full Bins : 28 + 32 31 + 29 M1 A1 2


The other 3 items (42, 41, 36) require 3 separate bins
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, 0 2
in a bin, so at least 5 bins will be required.
Note
1B1: Correct argument may be imprecise or muddled (bod gets B1)
2B1: A good, clear, correct argument. (They have answered
the question ‘why?’)
[9]

230
2. (a) = 3.83 so 4 needed M1 A1 2
60
Note
1M1: Their 230 divided by 60, some evidence
of correct method 3.8 enough.
1A1: cso 4.

Edexcel Internal Review 4


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

(b) Bin 1: 32 17 9 M1 A1
Bin 2: 45 12 A1
Bin 3: 23 28 A1 4
Bin 4: 38 16
Bin 5: 10
Note
1M1: Use of first fit. Probably 32, 45 and
17 correctly placed.
1A1: 32, 45, 17, 23, 38 and 28 placed correctly
2A1: 32, 45, 17, 23, 38, 28, 16, 9 placed correctly.
3A1: cao
Special case for (b) misread using first fit decreasing.
Give M1A1 (max)
Bin 1: 45 12
Bin 2: 38 17
Bin 3: 32 28
Bin 4: 23 16 10 9
M1 for placing 45, 38, 32, 28 and 23 correctly
A1 for cao.

(c) e.g. Bin 1: 32 28


Bin 2: 38 12 10 M1 A1
Bin 3: 45 9
Bin 4: 23 17 16 A1 3
Note
1M1: Use of full bin – at least one full bin
found and 5 numbers placed.
1A1: 2 full bins found
Eg [32+28 and 38+12+10] [23+28+9 and 16+12+32]
[32+28 and 23+16+12+9] [38+12+10 and 23+28+9]
2A1: A 4 bin solution found.
[9]

Edexcel Internal Review 5


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

502
3. (a) = 5.02 so 6 tapes. Ml
100
Al 2
1M1 (502 ±40) ÷ 100 (maybe implicit)
1A1: cao 6 tapes

(b) Bin l: 29, 52 Bin 5: 47,38 Ml


Bin 2: 73 Bin 6: 61
Bin 3: 87 Bin 7: 41 Al
Bin 4: 74 Al 3

1M1 Bin 1 correct and at least 8 values put in bins


1A1: Condone one error, (e.g. extra, omission, ‘balanced’ swap).
2A1: All correct

(c) Binl: 87 Bin 4: 61,38 M1


Bin 2: 74 Bin 5: 52,47 A1
Bin 3: 73 Bin6: 41,29 Al 3
1M1 Bin 1 correct and at least 8 values put in bins
1A1: Condone one error, (e.g. extra, omission, ‘balanced’ swap).
2A1: All conect
[8]

4. (a) E.g. M1 A1 A1ft A1ft A1 5


650 431 245 643 455 710 234 162 452 134
650 643 710 455 431 245 234 162 452 134
650 710 643 455 431 245 452 234 162 134
710 650 643 455 431 452 245 234 162 134
710 650 643 455 452 431 245 234 162 134

(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 4
(c) eg.
4116
= 4.116 ∴ 5 bins needed ∴ optimal M1 A1ft 2
1000
[11]

Edexcel Internal Review 6


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

5. (a) Bin 1 – 75+20


Bin 2 – 70 +20 M1
Bin 3 – 60+40 A1
Bin 4 – 50+35 A1
Bin 5 – 20
5 Planks needed: cost £15 A1
Wastage = 5+10+0+15+80 = 110cm A1 5

(b) Bin 1 (1.5m) – 75 + 70 Bin 1 (1m) –75 + 20 M1


Bin 2 (1.5m) – 60 + 50 + 40 or Bin 2 (1.5m) –70 + 60 + 20
Bin 3 (1m) – 35 + 20 + 20 + 20 Bin 3 (1.5m) –50 + 40 + 35 + 20 A1
Cost £11 A1
1.5m lengths better value than 1m lengths to use as many as possible A1 4
[9]

6. (a) (i) le ft to right or right to le ft


25 22 30 18 29 21 27 21 25 22 30 18 29 21 27 21 M1
25 30 22 18 29 21 27 21 25 22 30 18 29 27 28 21
25 30 22 29 18 21 27 21 25 22 30 29 18 27 21 21
25 30 22 29 21 18 27 21 25 30 22 29 18 27 21 21
25 30 22 29 21 27 18 21 30 25 22 29 18 27 21 21 A1 (pass)
(ii) 25 30 22 29 21 27 21 18 30 29 25 22 27 18 21 21
30 25 29 22 27 21 21 18 30 29 27 25 22 21 18 21
30 29 25 27 22 21 21 18 30 29 27 25 22 21 21 18
30 29 27 25 22 21 21 18 30 29 27 25 22 21 21 18
30 29 27 25 22 21 21 18

(b) (i) rod 1 30 18


2 29 21
3 27 22 M1 (to the 22)
4 25 21 A1 2

(ii) 193 ÷ 50 = 3.86, ∴ 4 rods needed, so minimum M1 A1 2


[9]

Edexcel Internal Review 7


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

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

2. This was often a good source of marks for candidates. Most were able to calculate the lower
bound getting 3.8 and therefore 4 bins. Most candidates applied first fit correctly, although some
candidates did not offer each item to each bin in turn, starting with bin 1 each time, so often the
9 was the first item to be misplaced. Some candidates wasted time by replacing each letter by a
number, or explaining in lengthy detail the steps they took to place each item. Not all candidates
realised that they should fill as many bins as possible when using full bin, most found one full
bin, but only the best found two.

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

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

Edexcel Internal Review 8


D1 Algorithms - Bin packing PhysicsAndMathsTutor.com

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

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

Edexcel Internal Review 9

You might also like