#ifndef QUEUELIST_H_ #define QUEUELIST_H_ #include "list.h" #include "magicqueue.h" template <typename T> class QueueList : public List<T> { private: MagicQueue <T> values; public: QueueList(); ~QueueList(); void insertAtHead(T item); void insertAtTail(T item); int getSize(); bool isEmpty(); // ...etc. all List methods are declared here }; #include "queuelist-inl.h" #endif
Using the above declarations, complete an implementation for the methods getSize(),insertAtHead(T item), and removeTail(). Your answers should be written as they would appear in queueList-inl.h, paying attention to the scope and template operators. Once complete, describe the O() of each of your methods. Again, the details of MagicQueue are not important; you should assume it implements a Queue interface properly in O(1) time.
wackyMergeSort(A, n): if (n <= 1) return A1 = new array A2 = new array copy first two-thirds (2n/3) of A into A1 copy last one-third (n-2n/3) of A into A2 wackyMergeSort(A1, 2n/3) wackyMergeSort(A2, n-2n/3) // merges sorted A1, A2 back into A merge(A1, 2n/3, A2, n-2n/3, A)