Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me to get a head start on coding in C++. Thanks. Ordered Priority Que (cpp file, that I need help with) should be

Please help me to get a head start on coding in C++. Thanks.

Ordered Priority Que (cpp file, that I need help with) should be implemented by calling methods from the OrderedArrayList.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.

AbstractList.h (header file, the declaration for Abstract list).

image text in transcribed

image text in transcribed

OrderedArrayList.h, class prototype defined in OrderedArrayList.h. A subclass of the pure virtual AbstractList class defined in its header file.

image text in transcribed

OrderedArrayList.cpp, The implementation.

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

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

image text in transcribed

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

image text in transcribed

I need help with writing C++ code for OrderedPQ.cpp - implementation for Ordered Priority Queue. Write code for the required public functions in OrderedPQ.h.

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

class OrderedArraylist : public Abstractlist \{ private: int* array; int capacity; int currentPos; public: OrderedArraylist(); OrderedArrayList(int initialCapacity); virtual bool add(int data); virtual bool add(int index, int data); virtual void clear(); virtual bool contains(int data); virtual int get(int index); virtual int index0f(int data); virtual bool isEmpty(); virtual int remove(int index); virtual bool removeAll(int data); virtual int size(); virtual void trimToSize(); \}; \#endif \} void OrderedArraylist: :trimToSize() \{ int *tmp = new int[currentSize]; capacity=currentSize;for(inti=0;i

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

Students also viewed these Databases questions

Question

What are possible results of sitting on emotions?

Answered: 1 week ago