-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsl_list.py
60 lines (44 loc) · 1.31 KB
/
sl_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
class SLNode:
def __init__(self, data):
self.data = data
self.front = None # can't use "next" - used by python.
def __str__(self):
'''Returns a string representation of an object for printing.
'''
pass
class SLList:
def __init__(self):
self.head = self.tail = None
self.size = 0
def __str__(self):
'''Returns a string representation of an object for printing.
'''
pass
def get(self, i):
'''SL.get(int) -> value
Returns the value stored at index, i.
Returns None if i \notin {0, ..., n-1}.
Runs in O(1+i) time.
'''
pass
def set(self, i, x):
'''SL.set(int, value) -> bool
Sets the element at index, i, to x and returns True.
Returns False if i \notin {0, ..., n-1}.
Runs in O(1+i) time.
'''
pass
def add(self, i, x):
'''SL.add(int, value) -> bool
Inserts x at index, i, and returns True.
Returns False if i \notin {0, ..., n}.
Runs in O(1+i) time.
'''
pass
def remove(self, i):
'''SL.remove(int) -> value
Removes the element at index, i, and returns it.
Returns None if i \notin {0, ..., n-1}.
Runs in O(1+i) time.
'''
pass