Interval DP (Preliminary understanding) _ Moving Gauge

Source: Internet
Author: User

The problem of interval dynamic programming is generally considered, for each interval, their optimal value is from a few sections of the best worth of smaller interval, is an application of the idea of partition, an interval problem is divided into smaller intervals until the interval of an element, enumerating their composition, to find the optimal value after the merger. Set F[i,j] (1<=i<=j<=n) represents the minimum cost minimum interval for the addition of numbers within the interval [i,j] f[i,i]=0 (one number cannot be merged and the ∴ cost is 0) each time, the interval is divided into [i<=k<=j-1] and by the variable K (i,k). [K+1,j] Two paragraphs

For the p:=1 to n do/p is the interval length, as the stage. For I:=1 to n do/I is the beginning of the exhaustive interval begin j:=i+p-1; J is the end of the interval, so that all the intervals are exhaustive. If J>n then break; This if is critical.  For k:= i-j-1 do//state transfer, to launch F[i,j] f[i, j]= max{f[i,k]+ f[k+1,j]+]} end; This structure must be well remembered, which is the code structure of the interval dynamic programming.

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.