Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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); cout  

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.

image text in transcribed

1 #include kiostream 2 #include 3 #include

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions