[algorithm] recursive equation divide-and-conquer _ recursion

Source: Internet
Author: User

This article according to Tsinghua University Deng Junhui teacher Curriculum "Data Structure" summary, course address. Recursive and recursive equations

From a recursive point of view, to solve the sum problem of array A, SUM (a,n), you need
-Recursive solution scale for n-1 problem sum (a,n-1)
-Tired plus a[n-1]

The recursive equation looks at its complexity,
T (n) t (0) =t (n−1) +o (1)//recurrence=o (1)//base:sum (a,0) (1) (2) (1) t (n) = t (n−1) + O (1)//R e C u r r e N c E (2) T (0) = O (1)//b a S e:s u m (A, 0)

Solution Process
Calculation of complexity

For the problem of sum of arrays, the common method is to write a loop to solve, and the complexity is O (n) o (n).

Using recursive analysis, can be decomposed into many child problems, the complexity of each trivial child problem is O (1) O (1), a total of n n processes. Therefore the complexity of the complex is O (n) o (n).

Reduction and treatment of

Decrease-and-conquer, in order to solve a large-scale problem, it can be divided into two sub problems: one ordinary, another scale reduction. The solution of the original problem is obtained by solving the sub problem separately.
Divide

Divide-and-conquer, in order to solve a large-scale problem, it can be divided into several (usually two) sub problems, the scale is roughly equivalent to solve the sub problem respectively. The solution of the original problem is obtained by the solution of the problem.

Common complexity issues

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.