算法导论--初级1
来源:互联网 发布:玩游戏花钱错了吗 知乎 编辑:程序博客网 时间:2024/05/17 07:50
算法分析是关于计算机程序性能(performance)与资源利用(communication, memory)的理论研究。Correctness, simplicity, maintainability, cost(time, robustness)feature, security, user-friendliness et al. may important than performance. performance会决定算法的feasible or infeasible,是算法实现的基础。performance应用于尚未成熟领域。
sorting problem:input sequence<a1,a2,……an>, output is permutation(rearrangement) of those numbers<b1,b2,……bn>, where b1<=b2<=……<=bn。
插入排序Insertion sort: sorting A[1..n]
for j <- 2 to n
do key <- A[j]
i <- j-1
while i > 0 and A[i] > key
do A[i+1] <- A[i]
i <- i-1
A[i+1]<-key
running time:input data itself(sorted), input data size(parametrize in input size), upper bounds(guarantee to user)
Worst-case analysis(usually): T(n):max time on any input of size n
Average-case analysis(sometimes): T(n):expected time over all inputs of size n(make an assumption of the statical distribution of the inputs -> expected time, uniform distribution)
Best-case(bogus假象):
for insertion sort:Asymptotic analysis渐近分析(ignore machine-dependant constants, look the growth of actual running time)
Worst-case: (in reverse order)T(n)=n^2,适合小数据,不适合大数据
并归排序Merge sort: sorting 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
Key subroutine: Merge, Time = n。
T(n) = 2T(n/2) + n , if n>1
~Recursion tree. -----T(n) = nlog n
- 算法导论--初级1
- 牛客网初级算法(1)
- 算法导论 1-1
- 算法导论 Theorem8.1
- 算法导论学习1
- 算法导论15.2-1
- 算法导论16-1
- 算法导论读书笔记1
- 深入浅出《算法导论》1
- 算法导论 1.1-1
- 算法导论 1.2-1
- 算法导论-1
- 算法导论 2-1
- 算法导论 3.1-1
- 算法导论 3.2-1
- 算法导论 4.1-1
- 算法导论 4.2-1
- 算法导论 4.3-1
- Scriptcase v8推出内部测试版及价格调整
- 小型企业网站上的东西去思考
- 程序链接后的变化
- 正则表达式验证邮箱,qq,座机,手机,网址
- 你Android手机中的数据信息:即便系统恢复出厂设置,手机中的数据信息还是能被轻而易举的找到
- 算法导论--初级1
- 每天一个linux命令(52):ifconfig命令
- 设计模式之命令模式
- WPF ,利用Winform库中的NotifyIcon实现托盘小程序
- 1.1.11 indexOf方法——返回第一次出现的索引位置
- (andriod)2dx fullPathForFilename 注意事项
- 寻找朋友为自己的英国斗牛犬幼犬
- 室内装饰技巧从总理Designersthe点才能获得理想的现代家具米娅
- 信息安全四条应对之策