Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

C++ (Templates Exercise) In this exercise, you'll be writing your Priority Queue. It must be stored in a specific file, PriorityQueue.h, which will contain the entire Priority Queue (i.e. don't...

1 answer below »
C++ (Templates Exercise)
In this exercise, you'll be writing your Priority Queue. It must be stored in a specific file,
PriorityQueue.h, which will contain the entire Priority Queue (i.e. don't separate it into a
PriorityQueue.cpp as well).
This Priority Queue has the following requirements:
• You may implement your Priority Queue contiguously (with an a
ay), or dynamically (with a linked
list), with the following restrictions:
â—¦ If you choose to go with a
ay, don't set the capacity in the constructor. Instead, use an expression
parameter to define the length of the a
ay
â—¦ If you go with a linked list, be careful with your memory management. Not only will you require a
destructor, but it will likely need a recursive function
• The Priority Queue must be templated
â—¦ It will require a single typename parameter, to indicate what it holds
â—¦ To that end, though you're free to use structs internally, you won't be using them from the client side,
unless what's being held just happens to be structs
â—¦ You'll have to write your enqueue method to accept two parameters: a T to store, and a long for
its priority
â—¦ This should go without saying, but because it's templated to hold any type, you obviously can't
hardcode any stored types
â–ª e.g. if you start writing it to hold strings for testing purposes, make sure you remember to delete
all occu
ences of 'string' from the final version
• As before, lower priority values have a higher priority for being removed
â—¦ e.g. if you add ("eenie", 33), ("meenie", 20), and ("miney", 40), then the first element to be removed
will be "meenie"
• In addition to enqueue and dequeue, also add:
â—¦ A bool isEmpty()
â—¦ A T peek(), to return what the next dequeue will return, but without actually removing it from the
Priority Queue
â—¦ An int count(), to return the cu
ent length of the Priority Queue
There should not be any cout (or cin) statements anywhere in your Priority Queue class!
Additionally, write a very simple program to demonstrate your Priority Queue.
For this client program, instantiate the Priority Queue to store std::strings, and let the user choose to add
and remove as many elements as they wish (with whatever priorities they like), until they choose to quit.
Requirements for Submission:
For your submission, in addition to including your source files, also include a sample execution or two.
Pack it all up into a .zip to submit.
Answered 3 days After Nov 03, 2022

Solution

Nidhi answered on Nov 05 2022
51 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here