cps6-111201Handout

cps6-111201Handout - Step 2: Swap it with the value in the...

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 December 1, 2011 Prof. Rodger Announcements • Read for next time Chap 11.3-11.6 • RQ on Blackboard – Due before class next time • Assignment 7 due 12/6 • APT 6 due 12/8 Comparison • Linear Searches vs Binary search • If there are N elements in the list – In the worst case, how many elements do you need to look at to find an item? – What is the fewest number? – What happens as N gets larger in both cases? Thinking about Sorting Jannie Tan • Is sorting important? • Is it a common problem? • In what contexts do you encounter sorting?
Background image of page 1

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

View Full DocumentRight Arrow Icon
Selection Sort • Step 1: Find the minimum value
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: 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.

Page1 / 3

cps6-111201Handout - Step 2: Swap it with the value in the...

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