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]
4 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]4 years ago
4 0

xekksksksksgBcjqixjdaj

You might be interested in
1. Reference initials are always typed on a business letter.
solniwko [45]

Answer:

1. true 2.false 3.a 4.d 5.c 6.d 7. true 8.true 9.true 10.true

Explanation:

5 0
4 years ago
According to the reading on the course web pages, the earliest usage of cooking began around _____ million years ago.
fenix001 [56]

Answer:

According to the reading on the course web pages, the earliest usage of clothes began around ____ million years ago. 3.4 1.5 0.8 0.5 1.7 2. According to the reading on the course web pages, lime mortar was probably discovered from annealing: Charcoal Obsidian Flint Glass 3.

Explanation:

6 0
3 years ago
Which action does not happen in each iteration of the repeat loop in the
iren2701 [21]

B. The number of sharks decreases. Explanation: hope it's help i learned about it and you too

7 0
3 years ago
Prereading strategies involve ООО introducing a text. previewing a text. summarizing a text. interpreting a text. ​
4vir4ik [10]

Answer:

A.

Explanation:

Mark Brainliest if correct!

5 0
3 years ago
What is the operating system in a computer?
vaieri [72.5K]

The answer to this question would be the last choice. The master program that controls the system hardware.

All computers require a software known as the <em>operating system</em> to properly function and allow you to use the computer. This operating system works as a "master program" that manages the computer's processes and memory.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which is NOT a way the network operating sys-
    6·1 answer
  • So im leavin brainly....goodbye. (❤´艸`❤)
    13·2 answers
  • Which hardware device should he consider upgrading in order to increase the system's storage space?
    6·1 answer
  • As you begin to develop a software application, what is one of the most helpful tools to ensure a quality product?
    12·1 answer
  • Describe a new career in computer science that may be created in the future. Include supporting evidence in your response that s
    13·1 answer
  • We can include following item(s) during configuration itemidentification:
    10·1 answer
  • Juan created new video game for his coding course. What is one way he can explain his code in everyday language?
    7·1 answer
  • What is considered an important ethical consideration when working with families
    13·1 answer
  • The cpu stores the results of computations in ________.
    8·2 answers
  • You can put ______ on your phone.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!