{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect_23 - Algorithms Margaret M Fleck 17 March 2010 This...

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

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

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.

{[ 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