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

Class Linked_List

Sorting Algorithms/Sorting_List.py:7–40  ·  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_End(self, new_data):
12 new_node = Node(new_data)
13 if self.head is None:
14 self.head = new_node
15 return
16 current = self.head
17 while current.next:
18 current = current.next
19 current.next = new_node
20
21 def Sort(self):
22 temp = self.head
23 while temp:
24 minn = temp
25 after = temp.next
26 while after:
27 if minn.data > after.data:
28 minn = after
29 after = after.next
30 key = temp.data
31 temp.data = minn.data
32 minn.data = key
33 temp = temp.next
34
35 def Display(self):
36 temp = self.head
37 while temp:
38 print(temp.data, "->", end=" ")
39 temp = temp.next
40 print("None")
41
42
43if __name__ == "__main__":

Callers 1

Sorting_List.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected