SDSU
CS 660: Combinatorial Algorithms
Review of Mathematical Analysis of Algorithms
----------
Contents of Intro Lecture
- References
- Mathematical Analysis of Algorithms
- Model of Computing
- Asymptotic Notation
- Timing Analysis
- Timing in C on Rohan
- Handling Measurement Errors1
- Estimating Complexity from Timing Results
- Mathematical Analysis and Timing Code
Introduction To Algorithms, Corman, Leiserson,Rivest, Chapters 1-4
If analysis of algorithms is the answer, what is the question?
Given two or more algorithms for the same task, which is better?
- Under which condition is bubble sort better than insertion sort?
What computing resources does an algorithm require?
- How long will it take bubble sort to sort a list of N items?
Goal of mathematical analysis is a function of the resources required of an
algorithm
On what computer?
What is a Computer?
Random-access machine (RAM)
- Single processor
- Instructions executed sequentially
- Each operation requires the same amount of time
-
Single cost vs. Lg(N) cost
- Time required for basic operation?
-
- 3 + 6
- 1234!
Insertion Sort
A[0] = - infinity
for K = 2
to N
do
begin
- J = K;
- Key = A[J];
- while Key < A[J-1] do
- begin
A[J] = A[J-1];
J = J - 1;
- end while;
- A[J] = Key;
end for;
Complexity
- Resources required by the algorithm as a function of the input
size
Worst-case Analysis
- Complexity of an algorithm based on worst input of each size
Average-case Analysis
- Complexity of an algorithm averaged over all inputs of each size
-
Insertion Sort
Comparisons Element moves