Kumar a Valu

10
Question 1: Six items with the weights given in the table are to be packed into boxes each of which has a capacity of 10 kg. Item A B C D E F Weight (kg) 2 1 6 3 3 5 i) Use the first-fit algorithm to pack the items, saying how many boxes are needed. ii) Give an optimal solution. Solution: A B C D E F 2 1 6 3 3 5 i) 1 st box - A+B+C - 2kg+1kg+6kg - 9kg 2 nd box - D+E - 3kg+3kg - 6kg 3 rd box - F - 5kg - 5kg

description

mathz

Transcript of Kumar a Valu

Page 1: Kumar a Valu

Question 1:

Six items with the weights given in the table are to be packed into boxes each of

which has a capacity of 10 kg.

Item A B C D E F

Weight (kg) 2 1 6 3 3 5

i) Use the first-fit algorithm to pack the items, saying how many boxes are

needed.

ii) Give an optimal solution.

Solution:

A B C D E F

2 1 6 3 3 5

i)

1st box - A+B+C - 2kg+1kg+6kg - 9kg

2nd box- D+E - 3kg+3kg - 6kg

3rd box - F - 5kg - 5kg

Three boxes are needed in order to pack the items using the first-fit algorithm. The

combination in each in box has been mentioned above.

ii)

1st box - A+E+F - 2kg+3kg+5kg - 10kg

2nd box- B+C+D - 1kg+6kg+3kg - 10kg

Here only two boxes had been used. Another thing that we should keep in mind,

there is no waste at all. This is the optimal solution that could be found used the full-

bins.

Page 2: Kumar a Valu

Question 2:

a)

The coach of a netball team has to arrange three pre-season training sessions, each

of length 90 minutes. She wants to schedule the activities which are listed below.

Some are to be scheduled more than once.

ActivityDuration

(m)

Numbers of times the activity is to be

scheduled

A Shooting practice 10 3

B Passing practice 15 3

C Blocking practice 12 3

D Sprinting 5 3

EIntermediate distance

running14 2

F Long distance running 20 1

G Team games 12 3

H 4-a-side practice game 20 2

I Full scale practice game 20 1

i) Use the first-fit decreasing algorithm to allocate activities to each of the three

training sessions.

ii) The solution given by the first-fit decreasing algorithm is not satisfactory

since it leads to repeated activities in the same session. The first-fit

decreasing algorithm is modified so that the next activity is placed in the first

available session only if it will fit and if the same activity has not already

been placed in that session.

iii) Prove that it is not possible to fit the activities into three sessions so that no

session contains a repeated activity.

Solution:

i)

F H H I B B B E E C

20 20 20 20 15 15 15 14 14 12

Page 3: Kumar a Valu

C C G G G A A D D D

12 12 12 12 12 10 10 5 5 5

1st training: F+H+H+I+A 20+20+20+20+10 = 90 min.

2nd training: B+B+B+E+E+C+D 15+15+15+14+14+12+5 = 90 min.

3rd training: C+C+G+G+G+A+A+D+D 12+12+12+12+12+10+10+5+5 = 90 min.

ii)

1st training: F, H, I, B, E

2nd training: H, B, E, C

3rd training: B, C

iii)

Since the activities such as A, B, C, D, and G were should be scheduled three times,

these activities will be placed in each training session. The total times which had

been covered by these activities are fifty-four minutes in each training session. In the

same time, each training sessions will have thirty-six minutes left. But, there are

four twenty minutes activities left to be scheduled. So, there will be two twenty

minutes activity will be listed in one training session. As there are only 36 minutes

available, there will not be a fit.

b)

At the end of pre-season training the coach has allocated points to ten players. She

will choose the seven highest scoring players for her team for the first match.

Player A B C D E F G H I J

Points 81 92 76 43 82 45 51 93 71 62

i) Count the number of comparisons she would have to make if she were to:

Page 4: Kumar a Valu

Check along the points table from the left to right, comparing the first

number with the second, then the larger with the third, and so on to

find the player with the highest score.

Choose that player for the team and delete the entry from the points

table

Repeat the process on the reduced points table until the team is

chosen.

ii) Instead she executes a bubble sort on the numbers in the list, starting

from the left and with smaller numbers moving to the right. She does this

only until she can be sure that the three lowest scores are in the three-right

positions. Show the steps of this sort, and state the number of comparisons

that are made.

Solution:

i)

1 2 3 4 5 6 7 8 9 = nu. of comparisons

A B C D E F G H I J

81 92 76 43 82 45 51 93 71 62

Players left Players Selected Number of comparisons

A,B,C,D,E,F,G,H,I,J H 9

A,B,C,D,E,F,G,I,J B 8

A,C,D,E,F,G,I,J E 7

A,C,D,E,G,I,J A 6

C,D,E,G,I,J C 5

D,E,G,I,J I 4

D,F,G,J J 3

TOTAL COMPARISONS 42

ii)

Page 5: Kumar a Valu

A B C D E F G H I J81 92 76 43 82 45 51 93 71 62

92 81 76 43 82 45 51 93 71 62

92 81 76 43 82 45 51 93 71 62

92 81 76 43 82 45 51 93 71 62

92 81 76 82 43 45 51 93 71 62

92 81 76 82 45 43 51 93 71 62

92 81 76 82 45 51 43 93 71 62

92 81 76 82 45 51 93 43 71 62

92 81 76 82 45 51 93 71 43 62

92 81 76 82 45 51 93 71 62 43B A C E F G H I J D

Here we have nine comparisons.

92 81 76 82 45 51 93 71 62 43B A C E F G H I J D

92 81 76 82 45 51 93 71 62 43

92 81 76 82 45 51 93 71 62 43

92 81 82 76 45 51 93 71 62 43

92 81 82 76 45 51 93 71 62 43

92 81 82 76 51 45 93 71 62 43

92 81 82 76 51 93 45 71 62 43

92 81 82 76 51 93 71 45 62 43

92 81 82 76 51 93 71 62 45 43B A E C G H I J F D

Page 6: Kumar a Valu

Here we are having eight comparisons. The last player in the list will be never

compared because he had confirmed the last place in the order.

92 81 82 76 51 93 71 62 45 43B A E C G H I J F D

92 81 82 76 51 93 71 62 45 43

92 81 82 76 51 93 71 62 45 43

92 82 81 76 51 93 71 62 45 43

92 82 81 76 51 93 71 62 45 43

92 82 81 76 93 51 71 62 45 43

92 82 81 76 93 71 51 62 45 43

92 82 81 76 93 71 62 51 45 43B E A C H I J G F D

Here we have seven comparisons. The last two players will be never compared

because they had confirmed their place. Totally we have 24 comparisons to be done

in this method to set the team.

Page 7: Kumar a Valu

Question 3:

Eleven boxes are to be packed into crates each of which has a weight limit of 100kg.

There are three boxes of weight 50kg, three of weight 40kg, three of weight 30kg

and two weight 20kg.

i) Apply the first-fit decreasing algorithm and state the number of crates used.

ii) Show that there is a solution using fewer crates.

Solution:

i)

50kg, 50kg, 50 kg, 40 kg, 40 kg, 40 kg, 30 kg,30 kg, 30 kg, 20 kg, 20 kg

1st crate - 50kg+50kg - 100kg

2nd crate - 50kg+40kg - 90kg

3rd crate - 40kg+40kg - 80kg

4th crate - 30kg+30kg+30kg - 90kg

5th crate - 20kg+20kg - 40 kg

Here five crates were have been used to pack the boxes.

ii)

1st crate - 50kg+50kg - 100kg

2nd crate - 40kg+40kg+20kg - 100kg

3rd crate - 30kg+30kg+40kg - 100kg

4th crate - 50kg+30kg+20kg - 100kg

The solution which had been mentioned above is the solution which could be

achieved with the full-bins. Here only four crates will be used and no wasted space is

in the crates.