个人笔记-《高级数据结构》
- Why and how O(log n) access time?
- Dynamic data structure and Analysis
- Randomized Data Structure
- Augmented Data Structure
- Data Structures in Distributed Environments
- Data Structures in Frontiers of Research
- Exam
逆序对
- 随即序列 逆序对为 n(n-1)/4- 证明:全逆序序列 ,如 5,4,3,2,1,则总计4+3+2+1,共Cn(2)个,即n(n-1)/2
- 交换相邻元素的本质:消除一对逆序
 
跳表
查找:
    p=top
    While(1){
        while (p->next->key < x ) p=p->next;
        If (p->down == NULL ) return p->next
        p=p->down ;
    }插入:
    int insert(val x){
        int i;
        int j = n; //n是当前表所拥有的level数
        cell *p[k]; //指针数组,用来保存每一层要插入元素的前驱
        cell *p1;
        p1 = top->next;
        while(p1){
            while(p1->next->val < x) p1=p1->next;
            if(j <= k){
                p[j-1] = p1; //保存每一层的指针
                p1 = p1->down; //指向下一层
                j--;
            }
        }
        //下面的代码是将x插入到各层
        for (i = 0; i<k; i++){
            if(p[i]==NULL){//k>n的情况,需要创建一个层
                //创建层的第一个元素,并将top指向它
                cell *elementhead = (cell *) malloc(sizeof(cell));
                element->val = -1;
                element->down = top;
                top = elementhead; 
                //创建最后一个元素
                cell *elementtail = (cell *) malloc(sizeof(cell));
                elementtail->val = 1;
                elementtail->next = elementtail->down = NULL;
                //在该层中创建并插入x
                cell *element = (cell *) malloc(sizeof(cell));
                element->val = x;
                elementhead->next = element;
                element->next = elementtail;
                element->down = p[i-1]->next;
            }
            //正常插入一个元素
            cell *element = ( 
                    
                     
                    
                 
                    
                
