Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ code. Unordered Priority Que (cpp file, that I need help with) should be implemented by calling methods from the UnorderedArrayList.cpp (provided below). Priority Queue.

C++ code.

Unordered Priority Que (cpp file, that I need help with) should be implemented by calling methods from the UnorderedArrayList.cpp (provided below).

Priority Queue. For this ADT, removal operations always return the object in the queue of highest priority that has been in the queue the longest. That is, no object of a given priority is ever removed as long as the queue contains one or more object of a higher priority. Within a given priority First-In-First-Out (FIFO) order must be preserved.

UnorderedArrayList.cpp, The implementation.

image text in transcribed

image text in transcribed

image text in transcribed

PriorityQueue.h, (header file, the declaration for Priority Queue.)

image text in transcribed

UnorderedPQ.h, (Unordered priority queue, A class prototype defined in UnorderedPQ.h. A subclass of the pure virtual PriorityQueue class defined in its header file)

image text in transcribed

-I need help with C++ code for UnorderedPQ.cpp (implementation for Unordered Priority Queue).

-Write code for the required public functions in UnorderedPQ.h.

-This should be implemented by calling the methods from UnorderedArrayList.cpp list class - (provided). Please show explanations/comments for the answers, so I will learn. Thanks.

lass PriorityQueue rotected: const int DEFAULT_MAX_CAPACITY =1000; dblic: I/ Inserts a new object into the priority queue. Returns true if Il the insertion is successful. If the PQ is full, the insertion Il is aborted, and the method returns false. virtual bool insert(int object) =0; I/ Removes the object of highest priority that has been in the II PQ the longest, and returns it. I/ Throws invalid_argument if the PQ is empty. I/ exception error message: "Cannot remove from empty queue" virtual int remove( =0; I/ Deletes all instances of the parameter obj from the PQ if found, and I/ returns true. Returns false if no match to the parameter obj is found. virtual bool deleteAll(int obj) =0; I/ Returns the object of highest priority that has been in the I/ PQ the longest, but does NOT remove it. I/ Throws invalid_argument if the PQ is empty. l/ exception error message: "Cannot peek from empty queue" virtual int peek ()=; I/ Returns true if the priority queue contains the specified element I/ false otherwise. virtual bool contains(int obj) =; I/ Returns the number of objects currently in the PQ. virtual int size()=; I/ Returns the PQ to an empty state. virtual void clear()=; I/ Returns true if the PQ is empty, otherwise false virtual bool isEmpty ()=0; I/ Returns true if the PQ is full, otherwise false. List based I/ implementations should always return false. virtual bool isFull ()=0

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Differentiate required and excess banks reserves.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago