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

Class Linked_List

Delete_Linked_List.py:7–42  ·  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 Delete(self, key):
22 temp = self.head
23 if temp is None:
24 return "Can't Delete!"
25 else:
26 if temp.data == key:
27 self.head = temp.next
28 temp = None
29 while temp is not None:
30 prev = temp
31 temp = temp.next
32 curr = temp.next
33 if temp.data == key:
34 prev.next = curr
35 return
36
37 def Display(self):
38 temp = self.head
39 while temp:
40 print(temp.data, "->", end=" ")
41 temp = temp.next
42 print("None")
43
44
45if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected