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
The internet is based on which three key technologies?.
BlackZzzverrR [31]

Answer:

The Internet is based on which three key technologies? TCP/IP, HTML, and HTTP client/server computing, packet switching, and the development of communications standards for linking networks and computers TCP/IP, HTTP, and packet switching client/server computing, packet switching, and HTTP e-mail, instant messaging, and newsgroups

Explanation:

8 0
2 years ago
SLA:
Sphinxa [80]

Answer:

Objective

1 . b

2.a

3.b

4.a

5.a

6.b

7.a

8.b

9.a

10.a

8 0
3 years ago
A life insurance salesperson who takes advantage of the foot-in-the-door phenomenon would be most likely to:________
4vir4ik [10]

Answer:

d. ask customers to respond to a brief survey of their attitudes regarding life insurance.

Explanation:

A life insurance policy can be defined as a contract between a policyholder and an insurer, in which the insurer agrees to pay an amount of money to a specific beneficiary either upon the death of the insured person (decedent) or after a set period of time.

A salesperson (sales representative) refers to an individual or employee who is saddled with the responsibility of taking orders from customers, as well as selling finished goods and services to consumers or end users.

A foot-in-the-door phenomenon can be defined as a compliance (persuasive) technique or tactics that assumes a person agreeing to perform a small request increases the likelihood of he or she agreeing to a subsequent larger request. Thus, it posits that when a person agrees to a small, it makes it difficult for him or her to decline a second, larger (bigger) request.

In this context, a life insurance salesperson who takes advantage of the foot-in-the-door phenomenon would most likely ask his or her customers to respond to a brief survey of their attitudes regarding life insurance.

7 0
3 years ago
What would be the best thing you could do to prepare yourself to work for a company that has embraced globalization?
labwork [276]
C would be the answer i choose
7 0
4 years ago
Read 2 more answers
Question 1
Ivanshal [37]

Answer:

Q1. B

Q2. D

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • Suppose you have an int variable called number. What Java expression produces the second-to-last digit of the number (the 10s pl
    13·1 answer
  • Which of the following is least likely checked by the comprehensive component monitor?
    7·1 answer
  • 1. Explain what is meant by the following data types:
    11·1 answer
  • What is the purpose of the operating systems processor management function
    7·1 answer
  • How do you get free Wifi on your phone without paying
    6·1 answer
  • Look at the trend in the US labor force participation rate. If increasing the number of women and men in the labor force can be
    13·1 answer
  • Social media is an effective form of e-commerce. True False
    12·1 answer
  • What word describes a violation of copyright laws? What rights do copyright holders have over their work of art
    5·2 answers
  • THE DIFFERENCE BETWEEN COPY AND PASTE AND CUT AND PASTE IS: *
    5·2 answers
  • You have an application running on multiple ec2 instances, however every time an instance fails, your users complain that they l
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!