subject

Problem: in the bin packing problem, items of different weights (or sizes) must be packed into a finite number of bins each with the capacity c in a way that minimizes the number of bins used. the decision version of the bin packing problem (deciding if objects will fit into < = k bins) is np-complete. there is no known polynomial time algorithm to solve the optimization version of the bin packing problem. in this homework you will be examining two greedy approximation algorithms to solve the bin packing problem.-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.- first-fit-decreasing: first sort the items in decreasing order by size, then use first-fit on the resulting list. implement in c++. both algorithms should be in a program called bin. cpp. 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. cppexample 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.21065 10 2 5 4 410204 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 6sample output: test case 1 first fit : 4 - first fit decreasing : 3test case 2 first fit : 15 - first fit decreasing : 10

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
In a heat transfer course, we can derive the equation for the temperature distribution in a flat rectangular plate. in this example, we will look at a plate at steadystate with three sides being held at t1, and one side held at t2. the temperature for any location on the plate, t(x,y), can be calculated by where create a function (prob3_5) that will take inputs of vectors x and y in feet, scalar n, scalars l and w in feet and scalars t1 and t2 in degrees fahrenheit. it will output a matrix t which is the temperature of each x and y locations. t will have the number of columns equal to the number of elements in x and rows equal to the number of elements in y. though this can be done without loops (perhaps more efficiently), your program must use a nested loop.
Answers: 2
question
Computers and Technology, 24.06.2019 20:30
How is energy expended in active transport
Answers: 1
question
Computers and Technology, 25.06.2019 04:50
Your program should prompt the user for the dimensions of the two squares matrices, making sure that the user input is greater than or equal to 4.[ yes, an example would be a4x4matrix]2.if the above is not met, prompt the user for a new value.3.now generate random integernumbers to fill both matrices.4.display these two matrices on the screen.5.multiply the two matrices and display the result on the scre
Answers: 2
You know the right answer?
Problem: in the bin packing problem, items of different weights (or sizes) must be packed into a fi...
Questions
question
Biology, 10.03.2020 01:39
Questions on the website: 13722361