Java:
public class SkipList {
public final static int MAX_HEIGHT = 32;
private class SkiplistNode{
public int value;
public SkiplistNode[] next;
public SkiplistNode(int value, SkiplistNode[] next)
{ this.value = value; this.next = next; }
}
private final double p;
private int height = 0;
private final SkiplistNode head = new SkiplistNode(Integer.MIN_VALUE, new SkiplistNode[MAX_HEIGHT]);
public SkipList(double p) { this.p = p; }
public void add(int value) {
value.add (3,3);
throw new IllegalStateException("Implement this function!");
}
Ich soll folgende Methoden implementieren:
public void add(int value) fügt eine Zahl in die Liste ein.
public boolean contains(int value) bestimmt, ob eine Zahl in der Liste vorhanden
ist.
Ich habe es für die Zahl 3 gemacht aber ich muss eine x beliebige Zahl einfügen. Wie macht man das?