博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dynamic Programming
阅读量:4151 次
发布时间:2019-05-25

本文共 1847 字,大约阅读时间需要 6 分钟。

Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems andstores the results of subproblems to avoid computing the same results again. Following are the two main properties of a problem thatsuggest that the given problem can be solved using Dynamic programming.

1) Overlapping Subproblems: Like Divide and Conquer, Dynamic Programming combines solutions to sub-problems. Dynamic Programming is mainly used when solutions of same subproblems are called again and again. In dynamic programming, computed solutions to subproblems are stored  so that these don’t have to be recomputed. There are following two different ways to store the values so that these values can be reused.

a) Memoization: The memoized program for a problem is similar to therecursive version with a small modification that itlooks into a lookup table before computing solutions. We initialize a lookup array with all initial values as NIL. Whenever we need solution to a subproblem, we first look into the lookup table. If the value wanted is there then we just return the value, otherwise we calculate the value and put the result inlookup table so that it can be reused later.

b) Tabulation: The tabulated program for a given problembuilds a table iteratively and returns the wanted entry from table.

Both tabulated and Memoized store the solutions of subproblems. In Memoized version, table is filled on demand while in tabulated version, it is filled iterativelyUnlike the tabulated version, all entries of the lookup table are not necessarily filled in memoized version. So how should us choose between Memoization and Tabulation?

2) Optimal Substructure: A given problems has Optimal Substructure Property if optimal solution of the given problem can be obtained by using optimal solutions of its subproblems.

转载地址:http://rhxti.baihongyu.com/

你可能感兴趣的文章
php程序员看过来,这老外是在吐糟你吗?看看你中了几点!
查看>>
为什么说程序员是“培训班出来的”就是鄙视呢?
查看>>
码农吐糟同事:写代码低调点不行么?空格回车键与你有仇吗?
查看>>
阿里p8程序员四年提交6000次代码的确有功,但一次错误让人唏嘘!
查看>>
一道技术问题引起的遐想,最后得出结论技术的本质是多么的朴实!
查看>>
985硕士:非科班自学编程感觉还不如培训班出来的,硕士白读了?
查看>>
你准备写代码到多少岁?程序员们是这么回答的!
查看>>
码农:和产品对一天需求,产品经理的需求是对完了,可我代码呢?
查看>>
程序员过年回家该怎么给亲戚朋友解释自己的职业?
查看>>
技术架构师的日常工作是什么?网友:搭框架,写公共方法?
查看>>
第四章 微信飞机大战
查看>>
九度:题目1008:最短路径问题
查看>>
九度Online Judge
查看>>
九度:题目1027:欧拉回路
查看>>
九度:题目1012:畅通工程
查看>>
九度:题目1017:还是畅通工程
查看>>
九度:题目1034:寻找大富翁
查看>>
第六章 背包问题——01背包
查看>>
51nod 分类
查看>>
1136 . 欧拉函数
查看>>