Question
Implement a generic ADT PriorityQueue.cpp and PriorityQueue.h provided below using C++ templates and a single linear linked list A priority queue is a queue in
Implement a generic ADT PriorityQueue.cpp and PriorityQueue.h provided below using C++ templates and a single linear linked list
A priority queue is a queue in which items are stored in an order determined by a numeric priority value; where a task with priority 1 comes before a task with priority 2. This interpretation means lower numerical value has a higher priority. Thus, a priority queue is not a FIFO structure.
Implement the functions provided within the table
Note: Queue Node is defined as a struct:
struct QueueNode{
ItemType info; int priority;
QueueNode * next;};
Here is an example of how it output would look like:
left is input and right is >>>>>>> output
PriorityQueue.cpp
#include
using std::exception; using namespace std;
template
template
template
}
template
}
template
}
template
template
template
template
template
template
template
template
-------------------------------------
PriorityQueue.h
#include
class FullQueue {};
class EmptyQueue {};
template
PriorityQueue(int max);
~PriorityQueue();
void MakeEmpty(); bool IsEmpty() const;
bool IsFull() const;
void Enqueue(ItemType newItem); void Dequeue(ItemType& item);
int Length();
int Peek();
ItemType PeekPriority() void PrintQueue(std::ostream &out);
private: int priority; ItemType* info; QueueNode
Enqueue0 Adds value at the appropriate position in the queue as determined by the numerio value priority. As in conventional English usage, lower numeric values correspond to a higher urgency, so that a task of priority 1 comes before a task with priority 2. If the Removes the value at the front of the queue and returns it to the caller. Calling ameter is it defaults to on a e throws an Peek0 Returns the value of the most urgent item in the queue without removing it from ue throws an Calling peek on an priority of the most PeekPriority 0 Returns the urgent item removing it from in the queue without throws arn MakeEmm GetLen PrintQueue0 Prints Queue items ordered from front to rear the queue. Calling peek on an emp Removes all elements from the Returns the number of elements currently in the IsEmpty 0 Returns true if the queue is empty and false otherwise IsFull 0 Returns true if the queue is full and false otherwise
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started