321-HW2 - q.Dequeue(temp); q.Enqueue(temp); } } 2....

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1. global_procedure Insert_In_Order ( ); /*! requires IS_ORDERED (q) ensures q is permutation of #q * <#x> and IS_ORDERED (q) !*/ { object Integer p; p = q[current]; while (q[current] < x) { object Integer temp; q.Dequeue(temp); q.Enqueue(temp); } q.Enqueue(x); while(q[current] != p) { object Integer temp;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: q.Dequeue(temp); q.Enqueue(temp); } } 2. global_procedure Sort ( alters Queue_Of_Integer&amp; q ); /*! ensures q is permutation of #q and IS_ORDERED (q) !*/ { if(q.Length() &gt; 1) { object Queue_Of_Integer q1; object Queue_Of_Integer q2; Split(q, q1, q2); Sort(q1); Sort(q2); Merge(q1, q2, q); } }...
View Full Document

This note was uploaded on 02/27/2012 for the course CSE 321 taught by Professor Bucci during the Winter '11 term at Ohio State.

Ask a homework question - tutors are online