
数据结构
Renaissancer
这个作者很懒,什么都没留下…
展开
-
4.1链表二叉树
头文件 LinkQueue.h:#includeusing namespace std;typedef char DataType;typedef struct bnode{ DataType data; struct bnode *lchild,*rchild;} Bnode,*BTree;typedef struct node{原创 2015-09-25 18:37:12 · 460 阅读 · 0 评论 -
伸展树Splay
Splay树,中文名一般叫做伸展树。和Treap树相同,作为平衡树,它也是通过左旋和右旋来调整树的结构。和Treap树不同的是,Splay树不再用一个随机的权值来进行平衡,而是用固定的调整方式来使得调整之后的树会比较平衡。在左旋右旋的基础上,Splay树定义了3个操作:1. Zig直接根据x节点的位置,进行左旋或右旋。该操作将x节点提升了一层。原创 2016-07-07 16:23:06 · 643 阅读 · 0 评论 -
SBT(Size Balanced Tree平衡树的一种)
这次要学习平衡树被称为SBT,其全称为Size Balanced Tree,由我国的陈启峰同学所提出。它是一种高度平衡的二叉树。其基本思想是根据每颗子树的大小,来对二叉树的形态进行调整。采用s[]数组来记录每颗子树的大小,比如s[T]就表示以T为根节点的子树的节点总数。特别的,如果T为空,那么S[T]=0。SBT通过两个性质来保证树的平衡性:s[T.right]≥s原创 2016-07-12 11:04:09 · 1162 阅读 · 0 评论 -
简单字典树Trie
代码一,正确AC,490ms,72M#include #include #include #include #include #define MAX 26using namespace std;struct Trie{ int num; Trie* next[MAX]; Trie() { num=0; for(int i=0;i<MAX;i++) next[i原创 2016-02-18 11:41:06 · 490 阅读 · 0 评论 -
4.2二叉排序树
头文件 BinSTree.h:#define maxsize 100typedef int KeyType;typedef struct{ KeyType key;}DataType;typedef struct BinSTreeNode{ DataType elem; struct BinSTreeNode *lchild; struc原创 2015-09-25 20:09:33 · 442 阅读 · 0 评论 -
3.1队列
#includeusing namespace std;#define MAXSIZE 100typedef struct{ int data[MAXSIZE]; int front,rear;}SeqQueue,*PSeqQueue;//初始化队列PSeqQueue Init_SeqQueue(void){ PSeqQueue Q; Q=(PS原创 2015-09-25 17:20:36 · 485 阅读 · 0 评论 -
1.2静态链表
#include#define MAXSIZE 100using namespace std;typedef struct { int x; int next;}SNode;typedef struct { SNode sp[MAXSIZE]; int SL;}StList,*PStList;//静态链表初始化PStList Cr原创 2015-09-25 17:01:53 · 410 阅读 · 0 评论 -
红黑树
/* 性质1. 节点是红色或黑色 性质2. 根是黑色 性质3. 每个红色节点的两个子节点都是黑色 (从每个叶子到根的所有路径上不能有两个连续的红色节点) 性质4. 从任一节点到其每个叶子的所有路径都包含相同数目的黑色节点 */ #includeusing namespace std;typedef int KeyType;typedef enum Color原创 2015-09-29 20:38:07 · 540 阅读 · 2 评论 -
2.1链式栈
#includeusing namespace std;//结点结构typedef struct node{ int data; struct node *next;}StackNode,*PStackNode;//栈typedef struct { PStackNode top;}LinkStack,*PLinkStack;//初始化栈原创 2015-09-25 17:11:21 · 379 阅读 · 0 评论 -
1.3顺序表
头文件:node.h#includeusing namespace std;#define MAXSIZE 100//顺序表类型typedef struct node{ int data[MAXSIZE]; int length;}SeqList,*PSeqList;//顺序表初始化PSeqList Init_SepList(void){原创 2015-09-25 17:07:12 · 465 阅读 · 0 评论 -
3.2链式队列
#includeusing namespace std;typedef struct node{ int data; struct node *next;}QNode,*PQNode;typedef struct { PQNode front,rear;}LinkQueue,*PLinkQueue;//初始化队列PLinkQueue Init_L原创 2015-09-25 17:24:19 · 357 阅读 · 0 评论 -
2.2栈
头文件 SeqStack.h:#includeusing namespace std;#define MAXSIZE 100typedef double DataType;typedef struct{ DataType data[MAXSIZE]; int top;}SeqStack,*PSeqStack;//初始化栈PSeqStack Init_原创 2015-09-25 17:18:06 · 406 阅读 · 0 评论 -
1.1单链表
#includeusing namespace std;typedef struct node{ int data; struct node *next;}LNode,*LinkList;//创建空单链表LinkList Creat_LinkList(void){ LinkList H=(LinkList)malloc(sizeof(LNode)原创 2015-09-25 16:58:45 · 340 阅读 · 0 评论 -
5.1图
头文件 Graph.h:#include#define MaxVertexNum 30#define INFINITY 30000#define VertexType char#define EdgeType intusing namespace std;typedef struct { VertexType vertexs[MaxVertexNum];//顶点原创 2015-09-25 19:48:45 · 406 阅读 · 0 评论 -
平衡树Treap
Treap每个节点的数据域包含2个值,key和weight。key值,和原来的二叉搜索树一样,满足左子树weight值,随机产生。在Treap中weight值满足堆的性质,根节点的weight值小于等于(或大于等于)左右儿子节点。比如下图就是一个示例的Treap:输入第1行:1个正整数n,表示操作数量,10≤n≤100,000第2..原创 2016-06-24 09:42:05 · 546 阅读 · 1 评论