1. Longest Increasing Subsequence (LIS) problem

unsorted array, calculate out the maximum length of subsequence with non-decreasing order.

lis[i] = lis[j] + 1 if arr[i] > arr[j]; lis[i] is the lis with arr[i] as the last element. so to get the maximum for the whole array, we should iterate the array and find out the max(lis[i])

complexity: O(n^2)

better algorithm: O(n logn): http://en.wikipedia.org/wiki/Longest_increasing_subsequence#Efficient_algorithms

2. Longest common subsequence

f[i][j] =  f[i-1][j-1]+1 if s1[i-1] == s2[j-1]

max(f[i-1][j], f[i][j-1]) else

3. edit distance

f[i][j] = f[i-1][j-1] if f[i-1] == f[j-1];

min(f[i-1][j], min(f[i][j-1], f[i-1][j-1])) + 1;

4. coin change

N cents, infinitely supply S = {S1, S2, ... Sm}, how many way to change it?

f[i][j] = f[i-s[j]][j] + f[i][j-1], i: the cents, j: using 0 to j Sj to change it.

5. matrix chain multiplication

for (L = 2; L < n; L++) {  // L is the chain length

  for (int i = 1; i <= n-L+1; i++) {

    j = i+L-1;

    m[i][j] = INT_MAX;

    for (int k = i; k <= j-1; k++) {

      q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];

      m[i][j] = min(m[i][j], q);

    }

  }

}

return m[1][n-1];

Algorithm: dynamic programming的更多相关文章

  1. [Algorithm -- Dynamic Programming] Recursive Staircase Problem

    For example there is a staricase N = 3 | ---|   |---|    | |---|            | ---|                  ...

  2. [Algorithm -- Dynamic programming] How Many Ways to Decode This Message?

    For example we have 'a' -> 1 'b' -> 2 .. 'z' -> 26 By given "12", we can decode t ...

  3. [Algorithm] Dynamic programming: Find Sets Of Numbers That Add Up To 16

    For a given array, we try to find set of pair which sums up as the given target number. For example, ...

  4. 以计算斐波那契数列为例说说动态规划算法(Dynamic Programming Algorithm Overlapping subproblems Optimal substructure Memoization Tabulation)

    动态规划(Dynamic Programming)是求解决策过程(decision process)最优化的数学方法.它的名字和动态没有关系,是Richard Bellman为了唬人而取的. 动态规划 ...

  5. Dynamic Programming

    We began our study of algorithmic techniques with greedy algorithms, which in some sense form the mo ...

  6. Dynamic Programming: From novice to advanced

    作者:Dumitru 出处:http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=dynProg An impo ...

  7. [算法]动态规划(Dynamic programming)

    转载请注明原创:http://www.cnblogs.com/StartoverX/p/4603173.html Dynamic Programming的Programming指的不是程序而是一种表格 ...

  8. hdu 4972 A simple dynamic programming problem(高效)

    pid=4972" target="_blank" style="">题目链接:hdu 4972 A simple dynamic progra ...

  9. Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical

    http://julialang.org/ julia | source | downloads | docs | blog | community | teaching | publications ...

随机推荐

  1. java.sql.Timestamp类型

    如果想向数据库中插入日期时间的话,可以用java.sql.Timestamp类 一个与 java.util.Date类有关的瘦包装器 (thin wrapper),它允许 JDBC API 将该类标识 ...

  2. 接口测试 rest-assured 使用指南

    转自:https://testerhome.com/topics/7060 原文:https://github.com/rest-assured/rest-assured/wiki/Usage本文gi ...

  3. Leetcode 编程训练(转载)

    Leetcode这个网站上的题都是一些经典的公司用来面试应聘者的面试题,很多人通过刷这些题来应聘一些喜欢面试算法的公司,比如:Google.微软.Facebook.Amazon之类的这些公司,基本上是 ...

  4. InnoDB Insert(插入)操作(下)--mysql技术内幕

    接上一篇文章,最后做的那个实验,我是想证明mysql innodb存储引擎,commit操作与flush数据到磁盘之间的关系,当与同事交流之后,他说,你应该把innodb_buffer_size的大小 ...

  5. C++中全局变量如何使用

    运行文件的小技巧:包含2个.CPP和一个.H文件,必须一个.CPP一个.H一一对应.且C++中,只能运行一个项目,要想在多个文件中(.cpp)运行一个.cpp必须建立多个项目,或者将不允许运行的文件从 ...

  6. Nook 2 Root

        最后我还是忍不住root了它,用了差一点够一个月 1.备份2.root 3.装软件=====================================================1. ...

  7. 【转载】IIS与asp.net管道

    阅读目录 asp.net是什么 HTTP协议 IIS与asp.net asp.net管道 参考资料 我们在基于asp.net开发web程序,基本上都是发布部署到安装了IIS的windows服务器上,然 ...

  8. spring源码解析之IOC容器(一)

    学习优秀框架的源码,是提升个人技术水平必不可少的一个环节.如果只是停留在知道怎么用,但是不懂其中的来龙去脉,在技术的道路上注定走不长远.最近,学习了一段时间的spring源码,现在整理出来,以便日后温 ...

  9. c# .net 我的Application_Error 全局异常抓取处理

    protected void Application_Error(object sender, EventArgs e)        {            //在出现未处理的错误时运行的代码   ...

  10. Mongodb亿级数据量的性能测试

    进行了一下Mongodb亿级数据量的性能测试,分别测试如下几个项目:   (所有插入都是单线程进行,所有读取都是多线程进行) 1) 普通插入性能 (插入的数据每条大约在1KB左右) 2) 批量插入性能 ...