[princeton/Algotithm I/week1](4) Analysis of Algorithms
1.4 Analysis of Algorithms
-
introduction
-
observations
-
mathematical models
-
order-of-growth classifications
-
theory of algorithms
-
memory
1.4.1 Introduction:
1. the cast of characters:
2.Focus on the running time:
Babbage machine - how many times do you have to turn the crank?
3. Algorithms performance
4. better performance (success algorithms)
minimize the running time
In the 1970s, Kanoof, use the scientific method to understand the performance of algorithms in operation.
5. Scientific method applied to analysis algorithms
1.4.2 Observations
1. running time of the program
Examples: 3-sum problem
2. measuring the running time
Plot running time T(N), input size N
3. log-log scale
Fit the line:
4. prediction and validation
5. ratios
6. Key factors determine the running time
1.4.3 Mathematical models
Cost of basic operations
Example: 1-Sum
Simplifying the calculation
Tilde notation
Example: 2-Sum
Example: 3-Sum
Estimating a discrete sum(calculus)
Mathematical models for running time
1.4.4 Order-of-growth classifications
Common order-of-growth classifications
Binary search demo
Mathematical analysis: Binary search
An
algorithm for 3-Sum
Compare running time
1.4.5 Theory of Algorithms
notations
example 1: 1-sum
example 2: 3-sum
The GAP between lower and upper bound
1.4.6 Memory