Question
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).
OrderedArrayList.h, class prototype defined in OrderedArrayList.h. A subclass of the pure virtual AbstractList class defined in its header file.
OrderedArrayList.cpp, The implementation.
PriorityQueue.h, (header file, the declaration for Priority Queue.)
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)
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
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