005-algorithm-Divide and conquer

Source: Internet
Author: User

I. Concept: in computer science, divide and conquer is an important algorithm paradigm based on multiple branch recursion. The literal explanation is "divide and conquer". It refers to dividing a complicated problem into two or more identical or similar subproblems until the subproblems can be solved simply and directly, the solution of the original problem is the merge of the solutions of the subproblem.

This technique is the basis of many algorithms in colleges and universities, such as sorting algorithms (fast sorting, Merge Sorting), Fourier Transformation (Fast Fourier transformation) Ideas: 1. decomposition: the original problem is divided into several subproblems, which are relatively small and independent, in the same form as the original problem. 2. Solution: If the sub-problem is small in size and easy to solve, it will be solved directly. Otherwise, the sub-problems are solved recursively. 3. Merge: Merge the solutions of each subproblem into the solutions of the original problem. The splitting algorithm works in the following ways:
1) divide the problematic instance into several smaller instances, and it is better to have an equal scale (in fact, this is generally the case, and there are mostly two instances, note the recursive score !!!)

2) solve these small instances (generally use RecursionBut when the problem is small enough, you can use another algorithm (stop recursion ))

3) If necessary, merge the solutions to these minor problems to obtain the solution to the original problem (in fact, the essence of a divide and conquer algorithm lies in the process of merging and solving)

Do not ignore these three sentences !!! It is a summary of many sub-governance algorithm experiences. It helps you to consider how to use the sub-governance algorithm during analysis. Please note my comments in brackets !!!

Screenshot: http://www.cnblogs.com/kkgreen/archive/2011/06/10/2077923.html:

1) The idea of sub-Governance: It is generally implemented by recursion, to draw molecular problems, and to merge subproblems.

2) The main theorem should be familiar with it. Common Recursive formulas should judge its complexity at a glance.

3) merging and sorting, fast sorting, half-lookup, and binary tree traversal are all classic data structures and have been written before. For more information about the code, see the previous article.

Here we will review how they all use the policy of sub-governance from different perspectives. These contents should be very skillful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.