forked from HU-CS201-master/hw03-spring-18
-
Notifications
You must be signed in to change notification settings - Fork 6
/
skiplist_list.py
61 lines (48 loc) · 1.45 KB
/
skiplist_list.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
class SkiplistList:
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 get(self, i):
'''Returns the element at index i; None if i is inavlid.
i \in [0,n-1]
'''
pass
def set(self, i, x):
'''Sets the element at valid index i to x and returns the old
element. Returns None if i is inavlid.
i \in [0,n-1]
'''
pass
def add(self, i, x):
'''Adds x at valid index i, shifting subsequent elements to the
right, and returns True. Returns False if i is invalid.
i \in [0,n]
'''
pass
def remove(self, i):
'''Removes the element at valid index i, shifting subsequent
elements to the left, and returns the remove elements. Returns
None if i is invalid.
i \in [0,n-1]
'''
pass
def truncate(self, i):
# As described in Exercise 4.11
pass
def absorb(self, l2):
# As described in Exercise 4.12
pass