{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

5 - CMPSCI 187 Programming With Data Structures Lecture 5...

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

CMPSCI 187: Programming With Data Structures Lecture 5: Analysis of Algorithms Overview 16 September 2011

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

View Full Document
Analysis of Algorithms Overview • What is Analysis of Algorithms? • Being Usefully Vague About Functions • Important Classes of Growth Functions • Determining Time Complexity From Code
What is Analysis of Algorithms? • We want to talk about the resources, usually time, used by an algorithm, as a function of the input size. • The time may be different for different inputs of the same size -- we take the worst-case time because we want to make a guarantee to the user. • The time complexity of an algorithm is a function with the number of input bits as its input, and the worst-case running time (in seconds, say, or in clock cycles) as the output. • But such a function is very hard to work with. We need to develop a better mathematical way of talking about such functions, called asymptotic analysis or big-O notation .

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

View Full Document
• Let f(n) be the time (in seconds) that it takes to wash n dishes. • Individual dishes may be cleaner or dirtier, but say that the worst take 30 seconds. • In the Good Method, where the washing of later dishes doesn’t affect the earlier ones, we have that f(n) is at most 30n seconds. In the worst case where every dish is horribly dirty, we take exactly 30n seconds. • In the Bad Method, washing the i’th dish soils the Frst i-1 dishes.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 10

5 - CMPSCI 187 Programming With Data Structures Lecture 5...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online