# 6 kinds of analysis worst case usually average case

• No School
• AA 1
• 22

This preview shows page 6 - 15 out of 22 pages.

6
Kinds of analysis Worst-case (usually) Average-case (sometimes) Best-case
Worst-case: (usually) The worst-case efficiency of an algorithm is its efficiency for the worst-case input of size n, which is an input (or inputs) of size n for which the algorithm runs the longest among all possible inputs of that size. • T(n) = maximum time of algorithm on any input of size n.
Average-case: (sometimes) T(n) = expected time of algorithm over all inputs of size n. • Need assumption of statistical distribution of inputs.
Best-case: The best-case efficiency of an algorithm is its efficiency for the best-case input of size n, which is an input (or inputs) of size n for which the algorithm runs the fastest among all possible inputs of that size
How to devise(develop) algorithms Something of an art form Cannot be fully automated We will describe some general techniques and try to illustrate when each is appropriate
Expressing Algorithms Implementations Pseudo-code English My main concern here is not the specific language used but the clarity of your expression
Verifying algorithm correctness Proving an algorithm generates correct output for all inputs One technique covered in textbook Loop invariants: A loop invariant is a condition that is necessarily true immediately before and immediately after each iteration of a loop .
Analyzing algorithms The “process” of determining how much resources (time, space) are used by a given algorithm We want to be able to make quantitative assessments about the value (goodness) of one algorithm compared to another We want to do this WITHOUT implementing and running an executable version of an algorithm

#### You've reached the end of your free preview.

Want to read all 22 pages?

• Fall '19

### 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