随笔分类 -  数据结构与算法

摘要:#include "stdafx.h"#include <iostream>using namespace std;#define MAXSIZE 20typedef struct{ int r[MAXSIZE + 1]; int length;}SqList;//***********************************起泡排序*************************************beginvoid BubbleSort(SqList& L){ bool flag = false; for (int i = L.leng 阅读全文
posted @ 2012-09-04 19:27 venow 阅读(479) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>using namespace std;//获取next数组的值void GetNext(const char* pattern, int length, int *next){ int i = 0; next[i] = -1; int j = -1; while (i < length - 1) { if (-1 == j || pattern[i] == pattern[j]) { i++; j++; ... 阅读全文
posted @ 2012-09-03 19:29 venow 阅读(531) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>using namespace std;#define MAXSIZE 20typedef struct{ int r[MAXSIZE + 1]; int length;}SqList;typedef SqList HeapType;//***********************************选择排序*************************************begin//查找最小值int SelectMinKey(const SqList& L, i 阅读全文
posted @ 2012-08-28 20:33 venow 阅读(344) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <queue>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; _Node() { data = 0; left = NULL; right = NULL; }}Node, *_PNode;//创建二叉树利用先序创建/* ... 阅读全文
posted @ 2012-08-24 22:15 venow 阅读(309) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; bool isVisit; //后序遍历标志(非递归) _Node() { data = 0; left = NULL; right = NULL; isVisit = false; }}... 阅读全文
posted @ 2012-08-24 21:31 venow 阅读(1651) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <fstream>#include <iostream>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; int bf; //平衡因子 _Node() { data = 0; left = NULL; right = NULL; bf = 0; }}Node, *_PNode;//创... 阅读全文
posted @ 2012-08-23 19:54 venow 阅读(1167) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <queue>#include <stack>#include <Windows.h>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; _Node() { data = 0; left = NULL; right = NULL; }}Node, *... 阅读全文
posted @ 2012-08-20 19:49 venow 阅读(2037) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <Windows.h>using namespace std;#define INFINITY 65535#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//*********************************邻接矩阵***********************************begin//邻接矩阵typedef st 阅读全文
posted @ 2012-08-20 19:31 venow 阅读(5153) 评论(0) 推荐(1)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <Windows.h>using namespace std;#define INFINITY 65535#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//*********************************邻接表***********************************begintypedef char Vert 阅读全文
posted @ 2012-08-20 19:14 venow 阅读(374) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <Windows.h>#include <algorithm>using namespace std;#define INFINITY INT_MAX#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//********************************Kruskal(并查集实现)******************* 阅读全文
posted @ 2012-08-18 10:03 venow 阅读(1399) 评论(0) 推荐(2)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <queue>#include <stack>#include <Windows.h>using namespace std;#define INFINITY INT_MAX#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//邻接矩阵typedef struct _Graph{ int matrix[MAX_VERTE 阅读全文
posted @ 2012-08-18 09:53 venow 阅读(2108) 评论(0) 推荐(1)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <queue>#include <Windows.h>using namespace std;#define INFINITY INT_MAX#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//邻接矩阵typedef struct _Graph{ int matrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM] 阅读全文
posted @ 2012-08-18 09:47 venow 阅读(1645) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <Windows.h>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; bool isRed; //红黑树 _Node() { data = 0; left = NULL; right = NULL; isRed = true; }}Node, *_PN... 阅读全文
posted @ 2012-08-15 21:46 venow 阅读(672) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <queue>#include <Windows.h>using namespace std;#define INFINITY INT_MAX#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//*********************************邻接表********************************* 阅读全文
posted @ 2012-08-14 21:56 venow 阅读(2867) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <fstream>#include <queue>#include <Windows.h>using namespace std;#define INFINITY INT_MAX#define MAX_VERTEX_NUM 20 //顶点最多个数#define LENGTH 5 //顶点字符长度//邻接矩阵typedef struct _Graph{ int matrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM] 阅读全文
posted @ 2012-08-14 20:16 venow 阅读(3803) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <iomanip>#include <stack>#include <queue>#include <Windows.h>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; int bf; //平衡因子 _Node() { data = 0; left = NULL; ... 阅读全文
posted @ 2012-08-09 20:10 venow 阅读(538) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <iomanip>#include <stack>#include <queue>#include <Windows.h>using namespace std;enum TYPE{ TYPE_LINK = 0, TYPE_CLUES,};typedef struct _Node{ int data; struct _Node *left; struct _Node *right; bool isVisit; //用于后序 阅读全文
posted @ 2012-08-07 20:47 venow 阅读(363) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <iomanip>#include <stack>#include <queue>#include <Windows.h>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; _Node() { data = 0; left = NULL; right = NULL; }}Node, *_PN 阅读全文
posted @ 2012-08-07 20:20 venow 阅读(360) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include <iostream>#include <stack>#include <queue>#include <Windows.h>using namespace std;typedef struct _Node{ int data; struct _Node *left; struct _Node *right; bool isVisit; //用于后序非递归遍历,表示节点是否可以访问 _Node() { data = 0; left = NULL; r... 阅读全文
posted @ 2012-08-04 22:14 venow 阅读(907) 评论(0) 推荐(1)