Analysis Framework
- “Analysis of algorithms” mean an investigation of an algorithm’s efficiency with respect to two resources: running time and memory space.
- There are two kinds of efficiency:
- Time efficiency – how fast an algorithm runs.
- Space efficiency – how much memory an algorithm needs.
Measuring an input’s size
- It is logical to investigate an algorithm’s efficiency as a function of some parameter indicating the algorithm’s input size
- Selecting such a parameter is quite straightforward.
- For example,
- Sorting – An input size is the size of the list.
- Find the largest element in the list of an array
- Compute the sum of numbers.
Units for measuring running time
- Units for measuring running time is to count the number of times the algorithm’s basic operations is executed.
- The basic operation means the operation contributing the most to the total running time.
- The basic operation is usually the most time-consuming operation in the algorithm’s innermost loop.
- For example,
- Sorting – the basic operation is key comparison.
- For example,
-
= running time of an algorithm
-
= input size
-
= execution time of the basic operation
-
= number of times the basic operation is executed
-
How much longer will the algorithm run if we double its input size?
-
Assume that
-
Therefore,
-
We were able to answer the question without actually knowing the value of
-
We concentrate on the count’s order of growth for large-size inputs.
Orders of growth
- The magnitude of the numbers in the following table has a profound significance for the analysis of algorithms.

- Algorithms that require an exponential number of operations are practical for solving only problems of very small size.
- Basic asymptotic efficiency classes
| Class | Name |
|---|---|
| constant | |
| logarithmic | |
| linear | |
| linearithmic | |
| quadratic | |
| cubic | |
| exponential | |
| factorial |
Worst-case, best-case, and average-case
- There are many algorithms for which running time depends not only on an input size but also on the specifics of a particular input.
- The worst-case efficiency of an algorithm is its efficiency for the worst-case input of size , which is an input of size for which the algorithm runs the longest among all possible inputs of that size.
- The best-case efficiency of an algorithm is its efficiency for the best-case input of size , which is an input of size for which the algorithm runs the fastest among all possible inputs of that size.
- To analyze the algorithm’s average-case efficiency, we must make some assumptions about possible inputs of size .
Asymptotic notations
Analysis of Algorithms
Mathematical analysis of non-recursive algorithms
- General plan for analyzing time efficiency of non-recursive algorithms:
- Decide on a parameter indicating an input’s size.
- Identify the algorithm’s basic operation.
- Check whether the number of times the basic operation is executed depends only on the size of an input.
- How many times does the operation need to be executed.
- Set up a sum expressing the number of times the algorithm’s basic operation is executed.
- Using standard formulas and rules of sum manipulation, either find a closed form formula for the count or, at the very least, establish its order of growth.