-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray.py
More file actions
79 lines (55 loc) · 1.46 KB
/
Copy pathArray.py
File metadata and controls
79 lines (55 loc) · 1.46 KB
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
73
74
75
76
77
def createArray():
list = []
return list
def insertAtTheBeginning(list, value):
# Time Complexity - O(N)
list.insert(0, value)
def insertAtGivenIndex(list, value, index):
# Time Complexity - O(N)
list.insert(index, value)
return list
def insertAtTheEnd(list, value):
# Time Complexity = amortized O(1)
# append single value at the end of the string
list.append(value)
return list
def insertMultipleAtTheEnd(list, vallist):
# Time Complexity - O(N)
# list in which values need to be added
list.extend(vallist)
return list
def removeFromBeginning(list):
# Time Complexity - O(N)
# Removes single item from the list
list.pop(0)
return list
def removeFromIndex(list, index):
# Time Complexity - O(N)
# Removes single item from the list
del list[index]
return list
def removeFromEnd(list):
# Time Complexity - O(1)
# Removes single item from the list
list.pop()
return list
def removeFromValue(list, value):
# Time Complexity - O(N)
# Removes single item from the list
if value in list:
list.remove(value)
return list
def searchValue(list, value):
# Time Complexity - O(N)
if value in list:
idx = list.index(value)
return idx
return None
def clearList(list):
# Time Complexity - O(N)
# removes all the items from the list
list.clear()
return list
#deleteList
# Time Complexity - O(N)
#del(list)