-
Notifications
You must be signed in to change notification settings - Fork 3
/
skiplist.py
72 lines (59 loc) · 1.69 KB
/
skiplist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import random
class Skipnode:
def __init__(self, data, height):
'''Initializes node with data and (height+1) front pointers.
'''
pass
def __str__(self):
'''Returns a string representation of an object for printing.
'''
pass
def __repr__(self):
'''Returns a string representation of an object for interactive
mode.
'''
return self.__str__()
def height(self):
'''Returns the height of this node.
'''
pass
def add_levels(self, n):
'''Adds n front pointers.
'''
pass
class Skiplist:
def __init__(self, limit=100):
'''Initializes sentinel, height limit, and size.
'''
pass
def __str__(self):
'''Returns a string representation of an object for printing.
'''
pass
def __repr__(self):
'''Returns a string representation of an object for interactive
mode.
'''
return self.__str__()
def height(self):
'''Returns the height of the skiplist.
'''
pass
def find_predecessor(self, x):
'''Returns (predecessor_node, stack).
'''
pass
def find(self, x):
'''Returns x, its successor, or None, in that order.
'''
pass
def add(self, x):
'''Adds x to the skiplist and returns True; does not add and
returns False if x is already an element.
'''
pass
def remove(self, x):
'''Removes x from the skiplist and returns True; does not remove
and returns False if x is not an element.
'''
pass