{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cps6-111201Handout

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

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

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?

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

View Full Document
Selection Sort Step 1: Find the minimum value
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern