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
What is the function of ROM?
Gnoma [55]

Answer:

Hello, There!

<h2>Your Question↓</h2>

What is the function of ROM?

<h2>Answer↓</h2>

Allows parts of the computer to communicate is the Correct Answer.

Explanation:

<h2>Now you May Ask What does it do or How it works↓</h2>
  • ⇒ROM provides the necessary instructions for communication between various hardware components.
  • ⇒ it is essential for the storage and operation of the BIOS, but it can also be used for basic data management, to hold software for basic processes of utilities.

Tip: Wanna know how to earn points back for asking your Question?

If you do it's easy just when two people answer your question whichever answer you think is the best click the crown on the side to get 25% of your points back! :D

Therefore, I hope this helps!

6 0
2 years ago
Which of these is NOT one of the three parts to the event-handling mechanism in Java?
Tamiku [17]

Answer:Event action

Explanation:Event-handling mechanism is the technique through which the  the management of any event is Java is controlled and coordinated. The event handler code is used for the managing of the mechanism and execution.

Event action is not a part of the event handling mechanism in the java because no such step comes under the code of event handler and rest other option are present in java event handler.

5 0
2 years ago
A(n) _________________________ conveys a visual representation of data.
Komok [63]
I believe that the answer to fit this sentence is chart. Hope that this answer helped! ☺
3 0
3 years ago
PLEASE HELP! 25 POINTS!
irina [24]

Answer:

Its hard to answer unless im in the situation but id find a way to stop the car and figure out a way to get out and then call police

Explanation:

6 0
3 years ago
Read 2 more answers
Commands under menu bar in a computer
Brilliant_brown [7]

Answer:

File, Edit, and View

Explanation:

These are the standard ones that come with the software.

3 0
3 years ago
Other questions:
  • By generating and delivering timely and relevant information supported by networks, _____ creates new opportunities for conducti
    15·1 answer
  • What is the Most popular game out today?
    6·2 answers
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • me pueden ayudar con mi trabajo sii porfss si me dan la respuesta correcta y les doy la mejor coronita si​
    12·1 answer
  • Which logic correctly describes an algorithm to find the smallest of the three numbers a, b, and c and store the smallest number
    15·1 answer
  • What is the difference between EPROM and EEPROM, explain why​
    11·1 answer
  • How am i able to hear a presenter from a radio station through my fm tuner​
    14·1 answer
  • What type of software is an antivirus?
    5·2 answers
  • How are &lt; embed &gt; tags used in web page creation?
    5·1 answer
  • You have been asked to analyze the Excel data provided by your IT department. You would like to have the ability to sort and fil
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!