This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Algorithms Margaret M. Fleck 17 March 2010 This lecture starts the discussion of analyzing the running time of al- gorithms. This material is in sections 3.1 and 3.3 of Rosen. This was a half-lecture due to the quiz. 1 Introduction The main reason for studying big-O notation and solving recurrences is so that we can predict how fast different computer programs will run. This allows us to choose good designs for different practical applications. We will normally do these analyses only up to big-O, i.e. ignoring multiplicative constants and considering only the terms that dominate the running time. Over the next three lectures, we’ll look at basic searching and sorting algorithms, plus one or more other algorithms with similar structure (e.g. the Towers of Hanoi solver). When analyzing these algorithms, we’ll see how to focus in on the parts of the code that determine the big-O running time and where we can cut corners to keep our analysis simple. Such an approach may seem like sloppiness right now, but it becomes critical as you analyze more and more complex algorithms in later CS classes. 2 Linear Search Suppose that we have an array of real numbers a 1 , a 2 , ... a n and an input number b . The goal of a search algorithm is to find out whether b is in the list and, if so, at which array index it resides. Let’s assume, for simplicity, that the list contains no duplicates or (if it does) that our goal is to return 1 the first array position containing the value...
View Full Document
This note was uploaded on 09/21/2011 for the course CS 173 taught by Professor Erickson during the Spring '08 term at University of Illinois, Urbana Champaign.
- Spring '08