#ifndef TWOSTACKQUEUE_H_ #define TWOSTACKQUEUE_H_ #include "arraystack.h" #include "queue.h" template <typename T> class TwoStackQueue : public Queue<T> { private: ArrayStack<T> in; ArrayStack<T> out; public: void enqueue(T item); T dequeue(); T getFront(); int getSize(); bool isEmpty(); }; #include "twostackqueue.inl" #endif(The TwoStackQueue constructor and destructor are both empty and not shown.)
Using just the two Stacks in and out (and no other data), implement each queue function such that:
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) merge(A1, 2n/3, A2, n-2n/3, A) // merges sorted A1, A2 back into A