2012年3月3日

Splay树各操作--数组

摘要: 伸展树删除元素非常方便。。View Code #include <stdio.h>#include <string.h>#include <algorithm>#include <stdlib.h>#include <math.h>#include <algorithm>#include <time.h> using namespace std; int left[100010], right[100010], pf[100010];int value[100010];int num[100010]; //记录 阅读全文

posted @ 2012-03-03 22:44 more think, more gains 阅读(211) 评论(0) 推荐(0) 编辑

Treap树各种操作

摘要: 今天写了Treap树的各种操作。。1.插入元素2.删除元素3.查找元素4.求第K小元素5确定一个元素秩6求最大值7求最小值8遍历View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <time.h>typedef struct node{ node *lchild, *rchild, *pf;//左孩子,右孩子 int v, pri, size;//值和优先值}*Node;void update( Node &q ){ if( q->rc 阅读全文

posted @ 2012-03-03 21:53 more think, more gains 阅读(256) 评论(0) 推荐(0) 编辑

导航