CPE 103 Lab Activity

Priority Queue Implementation


This lab is an enhancement of Weiss Problem 6.27

You are to create an implementation of a priority queue.  (java.util already has one, but you are going to write one from scratch.)  

Your class is to be named ArrayPriorityQueue and it must implement this PriorityQueue Interface.

Here is the skeleton for ArrayPriorityQueue that you should complete.  Note that your solution must be generic. You may add instance fields to this class.

You are to implement the priority queue using an unsorted array.  Each enqueue operation is implemented by inserting the new item in the next available location in the array. 

Determine the Big-Oh running time for each of peek(), dequeue(), and enqueue().  Describe it in the method's javadoc comment.

The clear() operation must be performed in constant time (O(1)).

 @SuppressWarnings({"unchecked"})   may only be used on the constructor.

Write a JUnit test class named ArrayPriorityQueueStringTest that exercises your queue using Strings as elements.

Imagine that your class is going to be used in a help desk application that needs to prioritize outstanding issues that have to be resolved by help desk staff.  Create a class named Ticket that represents an issue.  The Ticket should have an ID number (a 5 digit number), a description of the problem, and a priority (a positive integer). 

Write a JUnit test class named ArrayPriorityQueueTicketTest that exercises your queue using Tickets as elements.

Submit your work as described in the syllabus.