cps6-111201

cps6-111201 - Step 1: Find the minimum value Step 2: Swap...

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 December 1, 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
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
Background image of page 2
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?
Background image of page 3

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

View Full DocumentRight Arrow Icon
Thinking about Sorting Jannie Tan • Is sorting important? • Is it a common problem? • In what contexts do you encounter sorting?
Background image of page 4
Selection Sort
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
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: 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

Page1 / 12

cps6-111201 - Step 1: Find the minimum value Step 2: Swap...

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