cps6-111206Handout

cps6-111206Handout - With each pass compare adjacent pairs...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CompSci 6 Introduction to Computer Science Dec 6, 2011 Prof. Rodger CSED Week, Dec 4-10 Make the pledge – csedweek.org Dec 7, 6:15pm, LSRC D106 Announcements • No Reading for next time • No Reading quiz • What’s due? – Assignment 7 due today, Dec 6, late by Dec 8 – Apt-06 due Thursday, Dec 8, late by Dec 10 – Cannot turn in anything late after Dec 10 • Assignments are being graded! Really!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
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? Bubblesort • N passes over the list
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: With each pass compare adjacent pairs and swap if out of order. Can examine one less element with each pass bubble up the next largest element in sorted order. Bubble Sort 11 8 3 17 22 12 9 5 Mergesort Start with small lists of size 1 each Merge 2 lists of size 1 into list of size 2 Merge 2 lists of size 2 into list of size 4 Merge 2 lists of size 4 into lists of size 8 Etc. Mergesort 11 8 3 17 22 12 9 5 Compare the sorts Compare with sizes of data, what happens with each sort as the size of the input doubles? Compare with different types of data Random data Reverse order Almost sorted...
View Full Document

Page1 / 3

cps6-111206Handout - With each pass compare adjacent pairs...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online