文件名称:treap代码实现
文件大小:21KB
文件格式:DOC
更新时间:2021-03-11 11:14:02
treap
void Insert(Node * &o,int x){//0为左子树,1为右子树 if(o==NULL){o = new Node(); o->ch[0]=o->ch[1]=NULL;o->key=x;o->weight=rand();} else{ int d=o->cmp(x); Insert(o->ch[d],x); if(o->ch[d]->weight>o->weight) rotate(o,d^1); } }