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 similarto a regular queue except each item added to the queue alsohas an associated priority. For this problem, make the priority an integer

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) add("Y", 1) g. q. add ("Z", 3) cout q remove Returns Y cout q remove Returns Z Returns x cout q remove You 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 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) add("Y", 1) g. q. add ("Z", 3) cout q remove Returns Y cout q remove Returns Z Returns x cout q remove You 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!