摘要: #include<iostream>#include <cmath>#include<vector>using namespace std;template <class T>void max_heap(T* heap, int i) //heap[0]存储堆的大小{ int l=2*i; //l为左孩子的结点编号 int r=2*i+1; //r为右孩子的结点编号 int largest=i; int heap_size=heap[0]; T temp; if(l<=heap_size && heap[l]>heap 阅读全文
posted @ 2012-12-25 00:35 busyfruit 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 参考算法导论,得出源程序如下:////动态规划法求最长公共子序列,参考算法导论15.4//#include<iostream>#include <vector>using namespace std;void lcs_length(const vector<char>& X, const vector<char>& Y, vector<vector<int> >& c, vector<vector<char> >& b) //X[1..m],Y[1..n],c[0.. 阅读全文
posted @ 2012-12-25 00:29 busyfruit 阅读(473) 评论(0) 推荐(0) 编辑