标签:des style blog color io os ar for sp
Analysis of Algorithms:
The analysis of algorithm is the theoretical study.(算法分析是理论研究)
The theoretical study of computer-program performance and resource usage.(理论研究是关于计算机性能和资源利用的研究)
In programming, what is more important than performance?
Why do we bother and why study algorithms and performance?
The problem of sorting(排序问题)
Such that:A1<A2<...<An
Insertion-Sort:
for (int i = 1; i < a.length; i++) { key=a[i]; int j=i-1; while (j>=0&&a[j]>key) { a[j+1]=a[j]; a[j]=key; j--; } for (int k = 0; k < a.length; k++) { System.out.print(a[k]+" "); } System.out.println(); }
}
running time:
one thing it depends on is the input itself.
--parameterize things in the input size.
Kinds of analysis:
What is insertion sorts worst-case time?
Depends n computer.
BIG Idea of algorithms:
on same machine analysis algorithms performance use asymptotic analysis(渐进分析)
asymptotic analysis:
asymptotic notation(渐进符号Θ)
Θ-notation:
Insertion-Sort worst-case sorted:T(n)=∑Θ(j)=Θ(n2)
Is insertion sort fast?
It‘s turns out for small n it is moderately fast;but it is not at all for large n.
Analysis of Algorithms--preface
标签:des style blog color io os ar for sp
原文地址:http://www.cnblogs.com/chuji1988/p/4008070.html