File tree 1 file changed +2
-8
lines changed
data_structures/LinkedList
1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ class Node:#create a Node
2
2
def __int__ (self ,data ):
3
3
self .data = data #given data
4
4
self .next = None #given next to None
5
-
6
5
class Linked_List :
7
6
pass
8
7
def insert_tail (Head ,data ):#insert the data at tail
@@ -19,8 +18,7 @@ def insert_tail(Head,data):#insert the data at tail
19
18
newNod .data = data
20
19
newNod .next = None
21
20
tamp .next = newNod #put the newnode into last node
22
- return Head #return first node of linked list
23
-
21
+ return Head #return first node of linked list
24
22
def insert_head (Head ,data ):
25
23
tamp = Head
26
24
if (tamp == None ):
@@ -33,20 +31,17 @@ def insert_head(Head,data):
33
31
newNod .data = data
34
32
newNod .next = Head #put the Head at NewNode Next
35
33
Head = newNod #make a NewNode to Head
36
- return Head
37
-
34
+ return Head
38
35
def Print (Head ):#print every node data
39
36
tamp = Node ()
40
37
tamp = Head
41
38
while tamp != None :
42
39
print (tamp .data )
43
40
tamp = tamp .next
44
-
45
41
def delete_head (Head ):#delete from head
46
42
if Head != None :
47
43
Head = Head .next
48
44
return Head #return new Head
49
-
50
45
def delete_tail (Head ):#delete from tail
51
46
if Head != None :
52
47
tamp = Node ()
@@ -55,7 +50,6 @@ def delete_tail(Head):#delete from tail
55
50
tamp = tamp .next
56
51
tamp .next = None #delete the last element by give next None to 2nd last Element
57
52
return Head
58
-
59
53
def isEmpty (Head ):
60
54
if (Head == None ):#check Head is None or Not
61
55
return True #return Ture if list is empty
You can’t perform that action at this time.
0 commit comments