1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olga_2 [115]
3 years ago
11

C++ 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 NPcomplete. There is no known polynomial time algorithm to solve the optimization version of the bin packing problem. In this homework you will be examining three 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.

- Best Fit: Place the items in the order in which they arrive. Place the next item into the bin which will leave the least room left over after the item is placed in the bin. If it does not fit in any bin, start a new bin.

Implement the algorithms in C++. Your program named bins.cpp 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. 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.

3

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

10

4

3 8 2 7

Sample output: Test Case 1 First Fit: 4, First Fit Decreasing: 3, Best Fit: 4

Test Case 2 First Fit: 15, First Fit Decreasing: 10, Best Fit: 15

Test Case 3 First Fit: 3, First Fit Decreasing: 2, Best Fit: 2
Computers and Technology
1 answer:
ipn [44]3 years ago
4 0

xekksksksksgBcjqixjdaj

You might be interested in
The following outline is used to plan a program. What is the name for this type of plan?
vladimir1956 [14]
Pseudocode is the answer
7 0
3 years ago
Read 2 more answers
The man-in-the-middle attack<br> means what
Tom [10]

Answer:

<em> where the attacker secretly relays and possibly alters the communications between two parties who believe that they are directly communicating with each other.</em>

Explanation:

4 0
3 years ago
Consider ________ when designing for display on a mobile device. font size all of these contrast small screen size
Delvig [45]
To be honest...i really dont know 
6 0
3 years ago
Read 2 more answers
What is profession explain with example​
WARRIOR [948]

Answer:   a profession is a job, or what you do for a living

example : a teacher is an example of proffesion

4 0
3 years ago
Read 2 more answers
Which data validation alert style should you use to prevent the user from entering invalid data?
mario62 [17]

Answer:

stop

Explanation:

If you set the error alert style to Stop, then you are asking Excel to prevent the user from typing in an invalid value.

5 0
2 years ago
Other questions:
  • Stores of data that are so large or complex that it is difficult to process them using traditional data base management applicat
    5·1 answer
  • Over the last few years, security cameras and other devices have become more common. Some people argue that these measures viola
    14·2 answers
  • What natural resource are available on the coast but not somewhereelse
    13·1 answer
  • A new product was introduced in 2003, which functions as both an identification device and a medium of communication. It uses in
    8·1 answer
  • How can I do a project with a model on the steam machine?
    14·1 answer
  • Which of the following is a strategy used to enhance communication in a presentation?
    14·1 answer
  • What happens when two computers have the same IP address?
    13·1 answer
  • All computers perform disk optimization utilizing the same software.<br><br> true <br> false
    11·1 answer
  • A ________ is a question you ask about data stored in a database
    9·1 answer
  • Help? Can you explain what this mean?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!