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. DedeCMS 列表页调用图集内容多张图片的方法

    新做一个以图片为主的网站,采用的DEDECMS图集,列表页要求直接调内容面的大图,解决方法如下:(主要是采用php的正则匹配函数preg_match_all函数来巩固复习下该函数:preg_match ...

  2. freemarker中include与import的区别

    在inc1.ftl与inc2.ftl中的内容分别是: <#assign username="刘德华">与<#assign username="张学友&q ...

  3. 转: Gradle:Gradle入门

    from: http://blog.csdn.net/p106786860/article/details/50422463

  4. linux中at命令

    名称 : linux at命令 使用权限 : 所有使用者 使用方式 : at -V [-q queue] [-f file] [-mldbv] TIME 说明 : linux at命令可以让使用者指定 ...

  5. Hibernate之load和get的差别

    load和get都会能够起到从数据库中获取持久态数据的作用.可是还有些略微的差别的. 參考以下的这个样例: @Test(expected = IllegalArgumentException.clas ...

  6. AutoIt3常见问题解答

    Q1 如何调试脚本? MsgBox(0,"测试",$var) ConsoleWrite("var=" & $var & @CRLF)   Q2 ...

  7. Struts2中Action自己主动接收參数

    Struts2中Action接收參数的方法主要有下面三种: 1.使用Action的属性接收參数:(通过属性驱动式)     a.定义:在Action类中定义属性,创建get和set方法.     b. ...

  8. Nexus 5刷阿里云OS

    刷机有风险,刷机需慎重! 1. 下载 recovery 的img和 阿里云os. recovery 的img下载: https://kanbox.com/f/V00KA 阿里云OS3.0.3 : 2月 ...

  9. Leetcode Array 11 Container With Most Water

    题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...

  10. robot framework selenium2library定位

    进行页面元素操作,最麻烦的莫过于元素定位了,经常提示element is not visible 或者element is not exist 下面介绍常见的定位方法和定位中的问题 1 使用name和 ...