Chapter 4: Performance Flashcards
5-step approach to the scientific method
- Observe some feature of the natural world
- Hypothesize a model that is consistent with the observations
- Predict events using the hypotheses
- Verify the predictions by making further observations
- Validate by repeating until the hypothesis and observations agree
Empirical analysis
A method whereby one develops a doubling hypothesis to double the size of the input and observe the effect on the running time.
2 Primary factors determining running time (Knuth)
- Cost of executing each statement
- The frequency of execution of each statement
Constant order of growth program
A program that executes a fixed number of statements to finish its job; consequently its running time does not depend on the problem size.
Linear order of growth program
A program whose running time is directly proportional to the problem size.
Ex.
Programs that spend a constant amount of time processing each piece of input data, or that are based on a single for loop.
Linearithmic order of growth program
A program whose running time for a problem of size N has order of growth N log N.
Quadratic order of growth program
N^2 order of growth
Ex.
Two nested for loops, used for some calculation involving all pairs of N elements.
Cubic order of growth program
N^3 order of growth
Ex.
Three nested for loops (Running time of matrix multiplication).
Exponential algorithm
Algorithm whose order of growth is b^N for any constant b>1