Question: Let say I have queue <12, 3, 7 , 90, 67, 54, 2, 9, 70>. The split functions should be able to split the queue

Let say I have queue <12, 3, 7 , 90, 67, 54, 2, 9, 70>. The split functions should be able to split the queue from the middle and make 2 queues q1, and q2 from it. The merge fuction need to be able to merge two different queues into one. The mergeSort function should be a recursive function that sort the queue. template <class T, class TCallback> void SortingMachine2::split(QueueOfT& q, QueueOfT& q1, QueueOfT& q2) //! clears q //! replaces q1, q2 //! requires: |q| > 1 //! ensures: perms(#q, q1 * q2) and //! floor(|#q|/2) <= |q1| <= ceiling(|#q|/2) and //! floor(|#q|/2) <= |q2| <= ceiling(|#q|/2) { } // split //---------------------------------------------------------------- template <class T, class TCallback> void SortingMachine2::merge(QueueOfT& q, QueueOfT& q1, QueueOfT& q2) //! replaces q //! clears q1, q2 //! ensures: sorted(q) and perms(q, #q1 * #q2) { } // merge //---------------------------------------------------------------- template <class T, class TCallback> void SortingMachine2::mergeSort (QueueOfT& q) //! updates q //! ensures: sorted(q) and perms(q, #q) //! decreasing: |q| { } // mergeSort

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!