Question
Implement a Priority Queue for strings. A priority queue is similar to a regular queue except each item added to the queue also has an
Implement a Priority Queue for strings. A priority queue is similar to a regular queue except each item added to the queue also has an associated priority. For this problem, make the priority an integer where 0 is the highest priority and larger values are increasingly lower in priority.
The remove function should return and remove the item that has the highest priority. For example:
q.add(X, 10); q.add(Y, 1); q.add(Z, 3); coutYou can implement the priority queue by performing a linear search in the remove() function.
Hint: Take a look at the Linked List code example from 03/30, which can downloaded from D2L. Reusing the code example is acceptable and modifying it is acceptable.
You are expected to use pointers. You will get a 0 if you use STL::priorityqueue or any other already-implemented priority queue data structure.
Important: Make sure to use the template provided since the test cases depend on it.
1 #include kiostream 2 #include3 #include
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