cps6-111206

cps6-111206 - • N passes over the list – With each pass...

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

View Full Document Right Arrow Icon
CompSci 6 Introduction to Computer Science Dec 6, 2011 Prof. Rodger
Background image of page 1

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

View Full DocumentRight Arrow Icon
CSED Week, Dec 4-10 Make the pledge – csedweek.org
Background image of page 2
Dec 7, 6:15pm, LSRC D106
Background image of page 3

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

View Full DocumentRight Arrow Icon
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 4
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?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Insertion Sort • 11 8 3 17 22 12 9 5
Background image of page 6
InsertionSort vs SelectionSort • How do these compare?
Background image of page 7

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

View Full DocumentRight Arrow Icon
Bubblesort
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • N passes over the list – 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

This document was uploaded on 01/17/2012.

Page1 / 12

cps6-111206 - • N passes over the list – With each pass...

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

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