首页 > 其他 > 详细

Algorithm: dynamic programming

时间:2014-02-10 16:45:27      阅读:379      评论:0      收藏:0      [点我收藏+]

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. 

Algorithm: dynamic programming

原文:http://www.cnblogs.com/yingzhongwen/p/3542664.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!