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
which tag does not display the text in the browser window and makes the sources code mode readable ?​
maxonik [38]

Answer:

HTML comments are not displayed in the browser, but they can help document ... You can add comments to your HTML source by using the following syntax: <! ... you can comment out HTML lines of code, one at a time, to search for errors: ... Use the HTML comment tag to make a comment out of the "This is a comment" text.

Explanation:

Gimme brainliest right now.

3 0
3 years ago
EIPP:________.
nikdorinn [45]

Answer:

D. All of these choices are correct

Explanation:

Electronic invoice presentment and payment, otherwise known as EIPP are business-to-business systems that combine e-invoicing and e-payment processes for the purpose of sending invoices to customers via Web portal or via a secure network by the use of a third party service provider. They are also used for receiving payer-initiated, third-party-processed, and ACH-network-settled wire transfers.

4 0
3 years ago
Read 2 more answers
1) List at least five smaller behaviors you could break the complex behavior "brushing my teeth" into.
zhuklara [117]
Q1:
1. Go into the bathroom
2. Put toothpaste on the toothbrush
3. Place head of toothbrush on your teeth
4. Revolve in small circles
5. Repeat 4 for all of your teeth
6. Use water to wash away the toothpaste in you mouth
5 0
3 years ago
Read 2 more answers
Which of the following statements regarding EFT is false? EFT still requires the endorsement of a check EFT allows payment to be
hammer [34]

A smart way of moving money from one personal banking account directly to another account is called EFT or electric fund transfer. There is a maximum clearance time of 24 hours for transfer.  The most widely-used program is Direct Deposit, in which payroll is deposited straight into an employee's bank account initiated through an electronic terminal, including credit card, Therefore, the following<span> statement regarding EFT is false?</span>

<span>1.                  </span><span>EFT still requires the endorsement of a check </span>

3 0
3 years ago
Protocols at which layer of the OSI model have the primary function of moving datagrams through an internetwork connected by rou
Vladimir [108]

Answer:

"Network layer" is the correct answer to the given question .  

Explanation:

The network layer is interconnected with different networks by providing permission to the network. This job is done by sending the packets in the network. The main aim of the network layer is to provide the logical addressing, routing, and fragmentation of packets.

The network layer is the layer of the OSI model whose primary function is moving the packets or datagrams in the internetwork which is connected by the routers.  

5 0
3 years ago
Other questions:
  • Marcus just created a new folder specifically for his buisness records so he would like to move last months business transaction
    13·2 answers
  • 4. Scientists are not concerned with the human impact on the environment. True or False?
    6·2 answers
  • Explicit knowledge can be documented and codified, whereas tacit knowledge encompasses insights, judgment, creative processes, a
    9·1 answer
  • In Microsoft Word, when you highlight existing text you want to replace, you're in
    7·1 answer
  • You have just purchased a motherboard that has an LGA 1156 socket for an Intel Pentium processor. What type of memory modules wi
    14·1 answer
  • What does it mean to say that data in an Excel table is “dynamically linked” to a chart? What are the advantages of this feature
    5·1 answer
  • HEPME <br> ZOOM<br> IN <br> STOP<br> GIVIJG<br> ME <br> LINKS <br> !!
    9·1 answer
  • Need help with a program to search to sort elements in an array.(increasing or decreasing order)
    8·1 answer
  • Which TWO of the following are input devices that are parts of a laptop computer?
    9·2 answers
  • (10 LC)
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!