This preview shows page 1. Sign up to view the full content.
Unformatted text preview: into the sorted list, leaving the entire collection of n + 1 elements correctly sorted. Thus, by the principle of Mathematical Induction, the theorem is correct. 7.2 void StackSort(AStack<int>& IN) { AStack<int> Temp1, Temp2; while (!IN.isEmpty()) // Transfer to another stack Temp1.push(IN.pop()); IN.push(Temp1.pop()); // Put back one element while (!Temp1.isEmpty()) { // Process rest of elems while (IN.top() > Temp1.top()) // Find elems place Temp2.push(IN.pop()); IN.push(Temp1.pop()); // Put the element in while (!Temp2.isEmpty()) // Put the rest back IN.push(Temp2.pop()); } } 46...
View
Full
Document
This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.
 Fall '08
 BELL,D

Click to edit the document details