This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Step 2: Swap it with the value in the first position Step 3: Keep going until the list is sorted CompSci 100e, Spring2011 5 Selection Sort picks the Smallest! SSS! Correctness Why is algorithm correct? Efficiency Is this algorithm efficient? Code Let's code it! Insertion Sort Maintain a sublist of sorted elements. For each item one at a time, insert it into the sorted sublist. N elements total How long does insertion sort take? Insertion Sort 11 8 3 17 22 12 9 5 InsertionSort vs SelectionSort How do these compare?...
View Full Document
This document was uploaded on 01/17/2012.
- Fall '09