# 漫谈算法（四）分治算法 Divide and Conquer Algorithm

Keywords: Divide and Conquer Algorithm; Mathematical Induction; Recurrence Tree; Master Theorem .

Divide and conquer (D&C) is an important algorithm design paradigm based on multi-branched recursion. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.

Recurrences go hand in hand with the divide-and-conquer paradigm, because theygive us a natural way to characterize the running times of divide-and-conquer algorithms.A recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs.

T(n) = 4T(n/2) + n，这个表达式就是我们的递归式。

1. Mathematical Induction 数学归纳法
2. Recursion Tree 画递归树找规律
3. Master Theorem 主定理(好像中文版的算法导论上就是这样翻译的，感觉真挫)

1. Mathematical Induction 数学归纳法

T(n) = T(n/2) + T(n/4) + T(n/8) + n

1）遇到T(n) = aT(n/b + d) + f(n)的时候，在绝大多数的情况下，我们可以直接忽略d来进行guess，因为当n足够大的时候 n/b + d 和 n/b 几乎是一样的。
2）guess的时候可以加一个常数项，比如上面guess T(n) = O(n)的时候，我们用的是 T(n)<= cn，有时候推导不顺利的时候，可以试试 用T(n) <= cn-d，这样可以摆脱一些常数项的干扰。
2. Recursion Tree 画递归树找规律

3. Master Theorm 主定理

========================================================================================

posted @ 2011-04-15 03:21  Gavin.Liu  阅读(14888)  评论(3编辑  收藏  举报