读书人

《Algorithms》第2章:Divide-and-con

发布时间: 2012-07-30 16:19:05 作者: rapoo

《Algorithms》第2章:Divide-and-conquer algorithms 学习笔记
1、《Algorithms》第2章:Divide-and-conquer algorithms  学习札记

2、高斯发现两个复数乘法初看涉及4次实数乘法运算,但实际上可以简化为3次乘法运算。例:(a+bi)(c+di) = ac - bd + (bc+ad)i ,其中bc+ad = (a+b)(c+d) - ac - bd所以只需计算(a+b)(c+d) 、 ac 和 bd。
这条原理可以帮助我们实现更好的乘法运算,将n位的x、y分成n/2位长,于是:《Algorithms》第2章:Divide-and-conquer algorithms  学习札记
运行时间:T(n) = 3T(n/2) + O(n), 解得时间复杂度为n^1.59, 比n^2效率更高。

3、依据以下定理可迅速写出时间复杂度。《Algorithms》第2章:Divide-and-conquer algorithms  学习札记

4、分治策略的典型应用:二分搜索和归并排序。二分搜索:T(n) = T(n/2) + O(1) ==> O(logn)归并排序:T(n) = 2T(n/2) + O(n) ==> O(nlogn)

归并排序代码(C++):