Question: Bin Packing problem description: Given an array of numbers, goal is to group them into minimum possible # of bins, but each bins items should

Bin Packing problem description: Given an array of numbers, goal is to group them into minimum possible # of bins, but each bins items should not go above fixed bin capacity of 100. Let us assume that array contents are already in sorted order.

However, in this lab, we are ONLY validating a possible solution - so, we need to get an array of numbers in one line, another set of numbers in the next line to get the bin assignments for each number & check whether it is a valid solution. Here are a few sample inputs & outputs:

Bin Packing problem description: Given an array of numbers, goal is to

First line has the input numbers, Second line has the bin assignments. 2 goes to bin 1, 5 goes to bin 2, 11 goes to bin 3, So this solution uses 4 bins with the following totals in each bin: 99, 97, 83, 88. So the solution is valid!

group them into minimum possible # of bins, but each bins itemsshould not go above fixed bin capacity of 100. Let us assume

that array contents are already in sorted order. However, in this lab,

21Valid52113323453782951990 Bin index 4 is used \& bin index 3 has been skipped - that is not valid. 20Bin501110totalgoesabove100320450781951992 Total of 78 and 95 goes above 100 . So, it is invalid. 20Bin50111111outofrange320450781952993 Bin 11 is out of range, since there are only 8 items in the input! There is absolutely no need to use more than 8 bins. Since input item 111 is above 100 so it cannot be accommodated in any bin - it is invalid input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!