The Divide-and-Conquer Paradigm分而治之范式

In general, the divide-and-conquer paradigm consists of the following steps.
The divide step. The input is partitioned into 1 p n parts.
The conquer step. This step consists of performing p recursive call(s) if the problem size is greater than some predefined threshold n 0 .
  The combine step. The solutions to the p recursive call(s) are combined to obtain the desired output.
 The combine step is very crucial to the performance of virtually all divide-and-conquer algorithms, as the efficiency of the algorithm is largely dependent on how judiciously this step is implemented .
 the divide step is invariant in almost all divide-and-conquer algorithms : Partition the input data into p parts, and proceed to the conquer step. In many divide-and-conquer algorithms, it takes O ( n ) time or even only O (1) time.
A divide-and-conquer algorithm has the following format .
 If the size of the instance I is “small”, then solve the problem using a straightforward method and return the answer. Otherwise, continue to the next step .
  Divide the instance I into p subinstances I 1 , I 2 , . . . , I p of approximately the same size.
  Recursively call the algorithm on each subinstance I j , 1 ≤ j ≤ p , to obtain p partial solutions.
 Combine the results of the p partial solutions to obtain the solution to the original instance I . Return the solution of instance I.

一般来说,分而治之模式包括以下步骤。

分割 步骤。输入被分割成 1≤p ≤ n 个部分。

治之 步骤。如果问题大小大于某个预定义阈值n0,则执行p 次递归 调用。

合并 步骤。将p 个递归 调用的解结合起来,以获得所需的输出。

合并步骤对几乎所有分而治之算法的性能都至关重要,因为算法的效率在很大程度上取决于如何明智地执行这一步骤。

几乎 所有的分而治之算法中,除法步骤都是不变的: 将输入数据分成p 部分 ,然后进入征服步骤。在许多分而治之算法中,这一步需要O(n) 时间,甚至只需要O(1) 时间。

分而治之算法的格式如下。

如果实例I 的大小"小",则使用直接方法解决问题并返回答案。否则,继续下一步。

将实例I 分成p 个子实例 I1、I2、...... , Ip大小大致相同。

在每个子实例Ij 上递归调用算法,1 ≤j ≤ p,得到p 个部分 解。

合并p 个部分 解的结果,得到原始实例I 的解。

  • 23
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值