mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-30 16:31:08 +00:00
Update singly_linked_list.py
This commit is contained in:
parent
48aa4c4a01
commit
f89d3a9ec3
|
@ -12,7 +12,7 @@ class Linked_List:
|
||||||
self.Head = None # Initialize Head to None
|
self.Head = None # Initialize Head to None
|
||||||
|
|
||||||
def insert_tail(self, data):
|
def insert_tail(self, data):
|
||||||
if(self.Head == None): self.insert_head(data) #If this is first node, call insert_head
|
if(self.Head is None): self.insert_head(data) #If this is first node, call insert_head
|
||||||
else:
|
else:
|
||||||
temp = self.Head
|
temp = self.Head
|
||||||
while(temp.next != None): #traverse to last node
|
while(temp.next != None): #traverse to last node
|
||||||
|
@ -50,7 +50,7 @@ class Linked_List:
|
||||||
return tamp
|
return tamp
|
||||||
|
|
||||||
def isEmpty(self):
|
def isEmpty(self):
|
||||||
return self.Head == None # Return if Head is none
|
return self.Head is None # Return if Head is none
|
||||||
|
|
||||||
def reverse(self):
|
def reverse(self):
|
||||||
prev = None
|
prev = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user