{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

L12cs2110fa09-6up

# L12cs2110fa09-6up - SEARCHING SORTING AND ASYMPTOTIC...

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

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 12 CS2110 Fall 2009

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

View Full Document
Announcements 2 Prelim 1 Thursday, October 15, 7:30 - 9pm, G01 Uris Topics all material up to (but not including) searching and sorting (this week’s topics) including interfaces & inheritance Exam conflicts A number of people will take P1 on the same day but from 6:00-6:30 (still Uris G01) Email me ASAP if you have a conflict but can’t solve it this way! A3 due Friday, October 10, 11:59pm Review sessions:
What Makes a Good Algorithm? 3 Suppose you have two possible algorithms or data structures that basically do the same thing; which is better ? Well… what do we mean by better ? Faster? Less space? Easier to code? Easier to maintain? Required for homework? How do we measure time and space for an algorithm?

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

View Full Document
Sample Problem: Searching 4 static boolean find(int[] a, int item) { for (int i = 0; i < a.length; i++) { if (a[i] == item) return true; } return false; } Determine if a sorted array of integers contains a given integer First solution: Linear Search (check each element) static boolean find(int[] a, int item) { for ( int x : a ) { if (x == item) return true; } return false; }