CSC151 2007S, Class 47: Insertion Sort Admin: * I will do my best to respect those of you who are silent today. * Distributed: Exam 3 (due next Friday). * EC for Saturday's Pride week march. * EC for War Requiem concert, 7:30 Sat. Darby * Reading for Monday: Merge Sort (may be edited). * The "overview" for today doesn't quite match because we did different things on Wednesday than I had planned. * I'm not particularly pleased with the recent drop-off in attendance. * NO QUIZ! Overview: * Some preparatory reflection on the reading. * Lab. == REFLECTION == What is the key idea in insertion sort? * Want to sort something * Do so by shuffling things around * How do we shuffle? * One strategy: Shift neighboring things that are out of order * Repeatedly insert values into * A list (if we're sorting lists) * The correct place in a vector (if we're sorting vectors) How does insertion sort differ in lists and vectors? * Lists: Build a new list and insert from left * Vectors: Rearrange, insert from right Why do we provide you with three different kinds of list-based insertion sort? (define numbers-insertion-sort (lambda (numbers) Only works with lists of numbers (define list-insertion-sort (lambda (lst may-precede?) Works with any kind of list Generalizes numbers-insertion-sort (define list-keyed-insertion-sort (lambda (lst get-key may-precede?) Works with any kind of list