Question: Implement First-Fit and First-Fit Decreasing in C++ First-Fit-Decreasing: First sort the items in decreasing order by size, then use First-Fit on the resulting list. First-Fit:
Implement First-Fit and First-Fit Decreasing in C++
First-Fit-Decreasing: First sort the items in decreasing order by size, then use First-Fit on the resulting list.
First-Fit: Put each item as you come to it into the first (earliest opened) bin into which it fits. If there is no available bin then open a new bin.
Implemention C++. Your program should read in a text file named bin.txt with multiple test cases as explained below and output to the terminal the number of bins each algorithm calculated for each test case. Your program should run with the command g++ bin.cpp
Example bin.txt:
The first line is the number of test cases, followed by the capacity of bins for that test case, the number of items and then the weight of each item. You can assume that the weight of an item does not exceed the capacity of a bin for that problem.
2
10
6
5 10 2 5 4 4
10
20
4 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 6
Sample output:
Test Case 1 First Fit : 4 - First Fit Decreasing : 3
Test Case 2 First Fit : 15 - First Fit Decreasing : 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
