Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code in JAVA In this lab, you will write a program in Java called BinPacker; it should take a bin value and a as

Please code in JAVA

In this lab, you will write a program in Java called BinPacker; it should take a bin value and a as command-line arguments. Input files contain a list of item sizes (all values will be positive integers), e.g.:

28

42

12

5

30

The objective of this lab is to test various strategies for the bin packing problem, see the following for more information about the problem:

https://en.wikipedia.org/wiki/Bin_packing_problem

Briefly, the problem is, given a list of items of various sizes (the values in file), find the fewest number of bins that hold all of the items, assuming each bin can hold no more that

values.

Notes:

  • You should implement the following strategies for solving the problem:

First-fit

The algorithm processes the items in the order they arrive. It attempts to place each item in the first available bin that can accommodate it. If no bin is found, it opens a new bin and puts the item into the new bin.

BestFitDecreasing

You put the next item into the bin that has the least remaining space among bins capable of storing the item. Use a binary search tree-based symbol table for this; create a method called bestfit(x) that takes an item size x and returns the bin whose remaining capacity is at least x and is closest to x. If no bins can hold x, create a new bin.

WorstFitDecreasing

You put the next item into the bin that has the most remaining space among bins capable of storing the item. Again, use a binary search tree-based symbol table for this; create a method called worstfit(x) that takes an item size x and returns the bin whose remaining capacity is the greatest and can hold x. If no bins can hold x, create a new bin.

  • If an item size exceeds the given bin capacity, print out a note saying that an item with greater weight than the bin capacity was encountered.

  • You may use a built-in BST class

Output:

Your program should print out the item placement achieved by each strategy. One average, which strategy works best. Can you come up with good cases for each strategy, where that strategy finds the best solution but the others do not?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago