#include <stdio.h>
#include <stdlib.h>

#define MAX_HOEHE 10

struct skip
{
	int hoehe;
	struct skip * next [MAX_HOEHE];
	int key;
};

struct skiplist
{
	struct skip * kopf;
	struct skip * end;
	int hoehe;
};

struct skip * new_skip ()
{
	int i;
	struct skip * s = malloc (sizeof (struct skip));
	s->hoehe = 0;
	for (i=0; i< MAX_HOEHE; i++) s->next[i] = 0;
	s->key = 0;
}

int random_hoehe()
{
	int i;
	int neue_hoehe = 0;
	for (i=0; i<MAX_HOEHE; i++)
	{
		if (rand () %2 == 1) // der würfel ist gefallen
		{
			neue_hoehe ++;
		} else {
			return neue_hoehe;
		}
	}
}

int insert (struct skiplist l, int x)
{
	struct skip *p = l.kopf;
	int neue_hoehe;
	int i;
	struct skip *update [MAX_HOEHE];

	for (i=l.hoehe; i>=0; i++)
	{
		while (p->next[i]->key < x) p = p->next[i];
		update[i] = p;
	}

	p= p->next[0];
	if (!(p->key == x)) // key must not exist
	{
		neue_hoehe = random_hoehe();
	}

}

int main()
{
	struct skiplist liste;
	liste.kopf = new_skip();
	liste.end  = new_skip();
	liste.hoehe=0;
	srand (10);
}

