cps6-111201

# cps6-111201 - • Step 1 Find the minimum value • Step 2...

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

CompSci 6 Introduction to Computer Science December 1, 2011 Prof. Rodger

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

View Full Document
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?

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

View Full Document
Thinking about Sorting Jannie Tan • Is sorting important? • Is it a common problem? • In what contexts do you encounter sorting?
Selection Sort

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • Step 1: Find the minimum value • 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

{[ snackBarMessage ]}

### Page1 / 12

cps6-111201 - • Step 1 Find the minimum value • Step 2...

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

View Full Document
Ask a homework question - tutors are online