Dynamic planning vs. divide-and-conquer strategy

Source: Internet
Author: User

• When solving problems by division, the number of sub-problems is often the exponential function of the problem size, so the time consumption is too large. • The idea of dynamic planning is that if each sub-problem is not independent, the number of sub-problems is only polynomial magnitude, and we can save the answers to the sub-problems that have been solved, and then find the answers when needed, so that a large number of repeated calculations can be avoided.

The basic idea is to use a table to record the answers to all the resolved sub-problems, whether or not the problem is used later, and if it is calculated, fill in the table with the results.

Netherfield argues//haha

intFintNintA[n]) {    if(n==0)return 0; if(n==1)return 1; A1=a[n-1]; A2=a[n-2]; if....  //using A1 and A2 instead of already calculated results, you can avoid a certain degree of recursion to reduce computational time and computational space    returnF (n1, a) +f (N-2, a);}

Dynamic planning vs. divide-and-conquer strategy

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.