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.