Course Address
Http://v.163.com/special/opencourse/algorithms.html
Today's course Address:
Http://open.163.com/movie/2010/12/G/F/M6UTT5U0I_M6V2T1JGF.html
Discussion performance
Analysis of algorithms:the Study of computer program performance ans resource usage.
Thinking:what is more important than performance?
Functionality, modularity, user-friendliness, security ...
Then why study ALGs and perf?
Performance is like the ' money ', you can buy other stuff ... This is a little bit of a deal.
Problem sorting
Insertion Sort
Every time I make sure I'm in the first place, it's sort.
8 2 4 9 3 6 i = 1
2 8 4 9 3 6 i = 2
2 4 8 9 3 6 i = 3
2 4 8 9 3 6 i = 4
2 3 4 8 9 6 i = 5
2 3 4 6 8 9 done
Running Time Analysis
- Depends on input (best case, Wrost case)
- Depends on input size
Wrost case, Ave case, best case
Analysis of BIG IDEA:ASYMPTOTC
- Ignore Machine Dependent
- Look at the growth
Θnotation, compared to n in the case of infinite big ~ so n^2 certainly faster than n^3.
Wrost Case:
Θ (n^2)
Merge sort a[1,..., N]
1, if n =1, done
2, recursively sort a[1,..., N/2] and A[N/2 + 1, ..., n]
3, merge 2 sorted lists
T (n) = 2T (N/2) +θ (n) if n > 1
T (n) = Cn*lgn +θ (n) =θ (NLGN) c stands for constant
Introduction to the algorithm of "lecture notes"