Write a program that implements these heurisitics in an efficient manner to find out how many bins are required for a random (uniformly distributed) sequence of N weights in the range 0 to u, using a priority queue. Your client programs should take N and u as command-line arguments so that, for example, java Assign6 100 .2 will generate 100 random weights between 0 and .2 and print out the total of the weights generated (best possible number of bins) and the number of bins resulting from applying the heuristic.
In addition to printing out the number of bins used, if N is less than or equal to 20, print out the weights generated and the contents of the bins in some reasonable format. Note that your program should be keeping track of the bin contents no matter what; it is just that these contents are printed only if N is sufficiently small.
Your code will declare a priority queue (BinaryHeap) of Bins. Each Bin keeps track of its contents. I would expect to see something along these lines:
class Bin implements Comparable { public Bin( int id, double firstItem ) { /* implementation not shown */ } void addItem( double x ) { /* implementation not shown */ } public String toString( ) { /* implementation not shown */ } public int compareTo( Object other ) { /* implementation not shown */ } // Other stuff as you see fit private int id; // The bin identifier (each bin gets a new one). private double howFull; // How full the bin currently is; ranges from 0 to 1 private List contents; // The contents of the bin; note shallowness };You can use java.util.Random class to get some random numbers To generate a uniformly distributed random number between 0 and u, generate one between 0 and 1, and multiply it by u.