#include
using namespace std;
class BRTree;
class BRTreeNode{
private:
friend class BRTree;
int key;
bool color;
int size;
BRTreeNode *left;
BRTreeNode *right;
BRTreeNode *parent;
public:
//创...
分类:
编程语言 时间:
2014-11-06 14:51:53
阅读次数:
227
伪代码:RECURSIVE-INSERT-SORT (A, n) if n>1 RECURSIVE-INSERT-SORT (A ,n-1) InsertLastNumber (A,n)InsertLastNumber (A,n) temp = A[n] i=n-1 whi...
分类:
编程语言 时间:
2014-11-06 00:26:59
阅读次数:
270
伪代码请见《算法导论》2.3节merge-sort实现:public class MergeSort { public static void sort(double [] A,int p, int r) { if(p<r) { int q = (int) Math.floor( (p+...
分类:
编程语言 时间:
2014-11-05 22:57:59
阅读次数:
259
伪代码:SELECTION-SORT1 for i=2 to A.length-12 max = A[i]3 mark = i4 for j=i+1 to A.length5 if A[j]>max6 max=A[j]7 mark = j8 A[m...
分类:
编程语言 时间:
2014-11-05 21:25:07
阅读次数:
171
算法导论,插入排序public class InsertSort { public static double [] sort(double [] num) { for(int i =1; i=0 && temp < num[j]) { ...
分类:
编程语言 时间:
2014-11-05 21:11:10
阅读次数:
187
今天在看代码源文件求diff的原理的时候看到了LCS算法。这个算法应该不陌生,动规的经典算法。具体算法做啥了我就不说了,不知道的可以直接看《算法导论》动态规划那一章。既然看到了就想回忆下,当想到算法正确性的时候,发现这个算法的正确性证明并不好做。于是想了一段时间,里面有几个细节很trick,容易陷进...
分类:
编程语言 时间:
2014-11-05 18:49:36
阅读次数:
230
求最大子数组的和,算法导论只分治递归求解,暴力求解,记忆扫描方法。...
分类:
编程语言 时间:
2014-11-04 09:25:49
阅读次数:
186
// ascvoid insertionSortAsc(vector &v){ int len = v.size(); for (int i = 1; i = 0 && v[j] > key) { v[j + 1] = v[j]; ...
分类:
编程语言 时间:
2014-11-03 22:09:00
阅读次数:
154