博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年8月22日

摘要: (1)分治法的3个步骤 设归并排序的当前区间是R[low..high],分治法的三个步骤是:①分解:将当前区间一分为二,即求分裂点 ②求解:递归地对两个子区间R[low..mid]和R[mid+1..high]进行归并排序;③组合:将已排序的两个子区间R[low..mid]和R[mid+1..high]归并为一个有序的区间R[low..high]。 递归的终结条件:子区间长度为1(一个记录自然有序)。(2)具体算法void MergeSortDC(SeqList R,int low,int high) {//用分治法对R[low..high]进行二路归并排序 int mi... 阅读全文

posted @ 2011-08-22 22:16 ChessYoung 阅读(782) 评论(0) 推荐(0) 编辑

摘要: 许多程序会大量使用字符串。对于不同的字符串,我们希望能够有办法判断其相似程序。我们定义一套操作方法来把两个不相同的字符串变得相同,具体的操作方法为: 1.修改一个字符(如把“a”替换为“b”); 2.增加一个字符(如把“abdd”变为“aebdd”); 3.删除一个字符(如把“travelling”变为“traveling”); 比如,对于“abcdefg”和“abcdef”两个字符串来说,我们认为可以通过增加/减少一个“g”的方式来达到目的。上面的两种方案,都仅需要一 次 。把这个操作所需要的次数定义为两个字符串的距离,而相似度等于“距离+1”的倒数。也就是说,“abcdefg”和“... 阅读全文

posted @ 2011-08-22 20:44 ChessYoung 阅读(308) 评论(0) 推荐(0) 编辑

摘要: #include "stdafx.h"#include <iostream>#include <assert.h>#include <string>#include <vector>using namespace std;template <typename T>class testclass{public: static int _data;};int testclass<int>::_data = 1;int testclass<char>::_data = 2;int _tmain(i 阅读全文

posted @ 2011-08-22 15:43 ChessYoung 阅读(156) 评论(0) 推荐(0) 编辑

摘要: #include "stdafx.h"#include <iostream>#include <vector>using namespace std;int _tmain(int argc, _TCHAR* argv[]){ vector<char> charVector; for (int x = 0; x < 10; ++x) { charVector.push_back(65+x); } int size = charVector.size(); for (int x = 0; x < size;++x) { ... 阅读全文

posted @ 2011-08-22 11:22 ChessYoung 阅读(402) 评论(0) 推荐(0) 编辑