Dynamic Planning Learning

Source: Internet
Author: User

Digital triangle problem

Http://sotong.sec.samsung.net/sotong/practice/practiceProbView.do?practiceProbId=AUkG9ZnV1GXVldGG

Consider the position (I,J) as a state, and then define the indicator function D (i,j) of the State (I,J): The maximum that can be obtained when starting from the position (I,J).

Recursive calculation:

int i,j;

Boundary Value Processing

for (j=1;j<=n;j++)

RESULT[N][J] = Data[n][j];

From the bottom up dynamic plan, save the leaf node to the maximum value of the current node

for (i=n-1; i>=1;i--)

for (j = 1; j<=i; j + +)

RESULT[I][J] =data[i][j]+max (result[i+1][j],result[i+1][j+1])

Memory Search:

memset (result,-1,sizeof (Result))

int solve (int i, int j)

{

Judge Result[i][j] >= 0 To determine if the node has been computed

if (Result[i][j] >= 0)

return RESULT[I][J];

return result[i][j] = Data[i][j] + (I==n?0:max (Solve (I+1,J), Solve (i+1,j+1)));

}

Sotong Similar topics:

Http://sotong.sec.samsung.net/sotong/practice/practiceProbView.do?practiceProbId=AUWlrlNFQzfVldEJ

Dynamic Planning (DP)

Coin problem:

There are n kinds of coins, denominations of V1, V2, V3,......, Vn, each with an unlimited number of coins, so that the sum of the par is exactly s, the maximum and minimum value of the output coins. -the longest and shortest path to the fixed end

Directed acyclic graph for dag (Directed acyclic graph)

BFS

Http://sotong.sec.samsung.net/sotong/practice/practiceProbView.do?practiceProbId=AUh3hAH1BFHVldFk

All-Purpose Templates:

Recommended URL:

http://poj.org/

Http://www.cnblogs.com/qiufeihai/archive/2012/09/11/2680840.html

Dynamic Planning Learning

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.