MCPcopy Create free account
hub / github.com/geekcomputers/Python / Linked_List

Class Linked_List

Rotate_Linked_List.py:7–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6
7class Linked_List:
8 def __init__(self):
9 self.head = None
10
11 def Insert_At_Beginning(self, new_data):
12 new_node = Node(new_data)
13 if self.head is None:
14 self.head = new_node
15 return
16 new_node.next = self.head
17 self.head = new_node
18
19 def Rotation(self, key):
20 if key == 0:
21 return
22 current = self.head
23 count = 1
24 while count < key and current is not None:
25 current = current.next
26 count += 1
27 if current is None:
28 return
29 Kth_Node = current
30 while current.next is not None:
31 current = current.next
32 current.next = self.head
33 self.head = Kth_Node.next
34 Kth_Node.next = None
35
36 def Display(self):
37 temp = self.head
38 while temp:
39 print(temp.data, "->", end=" ")
40 temp = temp.next
41 print("None")
42
43
44if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected