Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Test the following bin-packing algorithms:
(a) Next fit. (b) Firstfit.?(c) First fit decreasing.
Your program should run as follows:
./TestBinPackingAlgorithms
The should be an integer that corresponds to the number of items you will try to fit into bins. Your program should do the following:
// Generate a vector of N random numbers in the range [0.0, 1.0];
vector random_numbers = GenerateRandomNumbers(N);?
const int number_of_bins_next_fit = NextFitBinPacking(random_numbers);
const int number_of_bins_first_fit = FirstFitBinPacking(random_numbers);
// Sort the random_numbers from larger to smaller
std::sort(random_numbers.begin(), random_numbers.end(),
std::greater());?
const int number_of_bins_first_fit_decreasing = FirstFitBinPacking(random_numbers);

cout << "Number of bins:" << endl;

cout << "Next Fit: " << number_of_bins_next_fit << endl;
cout << "First Fit: " << number_of_bins_first_fit << endl;
cout << "First Fit Decreasing: " << number_of_bins_first_fit_decreasing << endl;
To generate a set of random numbers in the range [0.0, 1.0]:
#include
#include
using namespace std;
srand(time(0)); //use current time as seed for random generator
for (int i = 0; i < N; ++i) {
const double random_variable = (double)rand() % (double)RAND_MAX;
// Push it into the vector of random numbers.
}
You can use a naïve implementation for FirstFit. You don't have to keep track of the items per bin, but just the total number of bins. So each bin can be represented by the amount_of_space_used. An empty bin will have amount_of_space_used = 0.0, whereas for a full bin amount_of_space_used = 1.0;
You should expect FFD to be better than FF, and FF to be better than NF. Report your final results in your readme file.
}
Test for 50, 100, and 500 items.
--For extra credit you can implement FirstFitBinPacking using a more efficient implementation that requires a priority queue--

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91874105
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Mccann co has identified an investment project with the

McCann Co. has identified an investment project with the following cash flows. Year Cash Flow  1   $800  2    1,090 3    1,350 4    1,475 a. If the discount rate is 7 percent, what is the present value of these cash flow ...

At a certain temperature this reaction establishes an

At a certain temperature, this reaction establishes an equilibrium with the given equilibrium constant, Kc. Kc = 1.53 * 10^21 3A (g) + 2B (g) ------> 4C(g) If, at this temperature, 1.50 mol of A and 4.00 mol of B are pla ...

Use the management studio to create a new database called

Use the Management Studio to create a new database called Membership2 using the default settings. (If the database already exists, use the Management Studio to delete it and than recreate it)

Answer the following questions 1 suppose we want to

Answer the following Questions : 1. Suppose we want to transmit the message 1011101110 and protect it from using the CRC polynomial x 3 + x + 1. Use polynomial long division to determine the message should be transmitted ...

Given an undirected graph with both positive and negative

Given an undirected graph with both positive and negative edge weights, design an algorithm to find a maximum spanning forest with the largest total edge weights.

Assume you have been selected to build a system for

Assume you have been selected to build a system for Oil&Gas company. Do you prefer to build a win-based system or a web-based system? Why?

A compare the properties of cpu registers with the main

(a) Compare the properties of CPU registers with the main memory in MIPS.  (b) Describe the purpose of the stack pointer ($sp) for procedure calling. (c) What is a "basic block" and how is it used by a compiler? (d) Ther ...

My kids love playing uno and we just finished up an intense

My kids love playing UNO and we just finished up an intense round. Lets say that the deck has 80 cards. 20 red, 20 blue, 20 green and 20 yellow.  What is the probability of pulling 3 green cards if the first 2 are replac ...

Reconstructing binary trees via traversalsrecall the binary

Reconstructing Binary Trees Via Traversals Recall the binary tree data structure; recall three algorithms for traversing the tree: the inorder traversal, the preorder traversal, and the postorder traversal. 1. Suppose yo ...

Suppose that the demand curve for tickets to see a football

Suppose that the demand curve for tickets to see a football team play a game is given by Q = 80,000 - 40P and marginal cost is zero. The team's stadium can host 75,000 fans. i) How many tickets would the team sell if it ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As