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. python遍历当前目录并删除某文件

    #coding: utf-8 """ this programe is to clear driverlog below this dir __author__:the_ ...

  2. 在Android上编译OSG[3.0.2 ] (转)

    在Android上编译OSG[3.0.2 ] 分类:Android   This file contents can be applied for version OpenSceneGraph(OSG ...

  3. Linux学习之十八-sudo分权管理

    sudo分权管理 1.为什么需要sudo? 当我的主机是多人共管的环境时,如果大家都使用 su 来切换成为 root 的身份,那么就得每个人知道 root 的密码,这样密码太多人知道可能会流出去,很不 ...

  4. 2016.11.4 Injection of autowired dependencies failed

    运行项目时,提示错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...

  5. 转: 三大WEB服务器对比分析(apache ,lighttpd,nginx) (2008年的旧文,仅供参考之用)

    from:  http://www.blogjava.net/daniel-tu/archive/2008/12/29/248883.html 三大WEB服务器对比分析(apache ,lighttp ...

  6. linux中seq命令用法

    NAME seq - print a sequence of numbers SYNOPSIS seq [OPTION]... LAST seq [OPTION]... FIRST LAST seq ...

  7. jsp页面中,动态调用系统时间的实现

    在做WEB项目时,经常会须要 在页面中显示当前时间,以下介绍一个简单的调用系统时间的方法,效果如图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvczI5 ...

  8. vue 中 this.$router.push() 路由跳转传参 及 参数接收的方法

    传递参数的方法:1.Params 由于动态路由也是传递params的,所以在 this.$router.push() 方法中 path不能和params一起使用,否则params将无效.需要用name ...

  9. apache支持php

    #tarzxvf php-5.2.9.tar.gz #cdphp-5.2.9 #./configure--prefix=/usr/local/php --with-apxs2=/usr/local/a ...

  10. 将ActiveX控件标记为安全

    參考网页 http://msdn.microsoft.com/en-us/library/aa751977(v=vs.85).aspx http://support.microsoft.com/kb/ ...