算法练手
文章平均质量分 57
yangjianxuan
这个作者很懒,什么都没留下…
展开
-
红黑树——删除操作(未完成)
#include #include using namespace std; typedef enum { Red, Black, }Color; typedef struct Node { int key; Color color; struct Node *parent; struct Node *left; struct Node *right; }Node, *ptr原创 2014-04-17 16:26:46 · 218 阅读 · 0 评论 -
带头结点的双向循环链表
#include using namespace std; typedef struct Node { int data; struct Node* prev; struct Node* next; }Node, *ptrNode; class List { private: ptrNode linkList; int length; public:原创 2014-04-02 22:40:53 · 354 阅读 · 0 评论 -
堆排序
/* * HeapSort.cpp * * Created on: 2014年3月26日 * Author: yjx */ #include #include using namespace std; class HeapSort { private: vector vec; inline int parent(int i) { ret原创 2014-03-26 21:10:36 · 173 阅读 · 0 评论 -
快速排序
/* * test.cpp * * Created on: 2014-3-21 * Author: root */ #include #include using namespace std; class QuickSort { private: vector vec; public: void init(); void traverse(); int par原创 2014-03-27 10:08:24 · 210 阅读 · 0 评论 -
合并排序非递归实现
/* * MergeSort.cpp * * Created on: 2014-3-21 * Author: root */ #include #include using namespace std; class MergeSort { private: vector src; vector dst; void merge(vector::iterator i原创 2014-03-26 12:16:38 · 225 阅读 · 0 评论 -
二叉查找(排序)树
#include #include using namespace std; typedef struct Node { int value; struct Node *left; struct Node *right; }Node, *ptrNode; class BinaryTree { private: ptrNode tree; public:原创 2014-04-09 23:20:32 · 295 阅读 · 0 评论 -
二叉查找(排序)树——递归查找
#include #include using namespace std; typedef struct Node { int value; struct Node * left; struct Node * right; }Node, *ptrNode; class BinaryTree { private: ptrNode tree; public: void init()原创 2014-04-10 17:30:41 · 221 阅读 · 0 评论 -
二叉树各种非递归遍历——前序、中序、后序、层序遍历
#include #include #include using namespace std; typedef struct Node { int value; struct Node * left; struct Node * right; }Node, *ptrNode; class BinaryTree { private: ptrNode tree; public: v原创 2014-04-11 15:15:49 · 313 阅读 · 0 评论 -
二叉查找(排序)树——删除操作
#include #include using namespace std; typedef struct Node { int value; struct Node *left; struct Node *right; }Node, *ptrNode; class BinaryTree { private: ptrNode tree; public:原创 2014-04-10 21:09:41 · 211 阅读 · 0 评论 -
桶排序
#include #include #include using namespace std; class BucketSort { private: vector vec; vector > vecLis; public: void init(); void bucketSort(); void divide(); void collection(); int getInd原创 2014-03-28 18:46:15 · 161 阅读 · 0 评论 -
查找第i小的元素
#include #include using namespace std; class IthMin { private: vector vec; int ithMin; public: void init(); bool getIthMin(int k, int p, int r); int partition(int p, int r); void原创 2014-03-29 16:44:22 · 240 阅读 · 0 评论 -
中序线索二叉树
#include #include using namespace std; typedef enum { Link, Thread, } Tag; typedef struct Node { int value; Tag lTag; Tag rTag; struct Node *left; struct Node *right; } Node, *ptrNode; clas原创 2014-04-15 12:27:51 · 196 阅读 · 0 评论 -
查找最大最小值
#include #include using namespace std; class MaxMin { private: vector vec; int max; int min; public: void init(); void traverse(); void maxMin(); int getMax(); int getMin();原创 2014-03-29 14:58:30 · 371 阅读 · 0 评论 -
前序线索二叉树
#include #include using namespace std; typedef enum { Link, Thread, }Tag; typedef struct Node { int value; Tag lTag; Tag rTag; struct Node *left; struct Node *right; }Node, *ptrNode; class原创 2014-04-15 14:55:44 · 395 阅读 · 0 评论 -
后序线索二叉树
#include #include using namespace std; typedef enum { Link, Thread, }Tag; typedef struct Node { int value; Tag lTag; Tag rTag; struct Node *left; struct Node *right; }Node, *ptrNode; class原创 2014-04-15 15:53:13 · 500 阅读 · 0 评论 -
表达式求值
#include #include #include #include using namespace std; class Expression { private: string exp; stack st; stack res; public: void init(); int calculate(); int cal(int a, int b, char flag);原创 2014-04-01 13:04:43 · 211 阅读 · 0 评论 -
共享顺序双栈
#include using namespace std; class DoubleStack { private: static const int SIZE = 10; int data[SIZE]; int top1; int top2; public: void init(); bool isEmpty1(); bool isFull1();原创 2014-03-31 19:59:16 · 270 阅读 · 0 评论 -
红黑树——旋转、插入操作
#include #include using namespace std; typedef enum { Red, Black, } Color; typedef struct Node { int key; Color color; struct Node *p; struct Node *left; struct Node *right; }原创 2014-04-16 23:08:20 · 269 阅读 · 0 评论