摘要:跳跃表主要是用来减少查找的代价,作为单向链表,如果搜寻一个数据需要O(N)的时间代价,但是如果采用随机化跳跃表则可以大大减少搜寻代价.
(1)注意几个特点:
[1]跳跃表m阶指针所连接的元素至少具有m阶的指针.
[2]主要难点集中在查询,插入,以及删除操作.这比普通链表要复杂的多.
[3]首先看基本数据结构.
#include "stdafx.h"
#include "malloc.h"
#include "stdlib.h"
#include "time.h"
#define N 10
typedef struct Listrecord * List;
struct Listrecord
{
int Element;
int size;
List *Pointarray;
};
int GetRand()
{
int i,size = 0;
while(size <= N)
{
i = rand()%2;
if (i == 1)
size++;
else
return (++size);
}
return N;
}
void Initialize(List L,int size)
{