For this assignment, you will write one implementation of a Priority Queue. For this ADT, removal operations always return the object in the queue of highest priority that has been in the queue the longest. That is, no object of a given priority is ever removed as long as the queue contains one or more object of a higher priority. Within a given priority FIFO order must be preserved.
Your implementation will be:
1. BinaryHeap
The implementation must have identical behavior, and must implement the PriorityQueue interface (provided). The implementation must have two constructors, a default constructor with no arguments that uses the DEFAULT_MAX_CAPACITY constant from
the PriorityQueue interface, and a constructor that takes a single integer parameter that represents the maximum capacity of the priority queue.
The PriorityQueue interface follows:
/* The PriorityQueue ADT may store objects in any order. However,
// Inserts a new object into the priority queue. Returns true if // the insertion is successful. If the PQ is full, the insertion // is aborted, and the method returns false.
public boolean insert(E object);
// Removes the object of highest priority that has been in the
// PQ the longest, and returns it. Returns null if the PQ is empty. public E remove();
// Deletes all instances of the parameter obj from the PQ if found, and
// returns true. Returns false if no match to the parameter obj is found. public boolean delete(E obj);
// Returns the object of highest priority that has been in the // PQ the longest, but does NOT remove it.
// Returns null if the PQ is empty.
public E peek();
// Returns true if the priority queue contains the specified element // false otherwise.
public boolean contains(E obj);
// Returns the number of objects currently in the PQ. public int size();
// Returns the PQ to an empty state.
public void clear();
// Returns true if the PQ is empty, otherwise false public boolean isEmpty();
// Returns true if the PQ is full, otherwise false. List based // implementations should always return false.
public boolean isFull();
// Returns an iterator of the objects in the PQ, in no particular // order.
public Iterator<E> iterator();
}
Thus, your project will consist of the following files. You must use exactly these filenames.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more