-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNode_LL.py
More file actions
36 lines (26 loc) · 752 Bytes
/
Node_LL.py
File metadata and controls
36 lines (26 loc) · 752 Bytes
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
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Linked_List:
def __init__(self):
self.head = None
def Traverse(self):
temp = self.head
while temp:
print(temp.value)
temp = temp.next
def insert_start(self,new):
new.next = self.head
self.head = new
def insert_end(self,new):
temp = self.head
while temp.next:
temp = temp.next
temp.next = new
def insert_random(self, new, position):
temp = self.head
while temp.value != position:
temp = temp.next
new.next = temp.next
temp.next = new