Update singly_linked_list.py

This commit is contained in:
Ashwek Swamy 2018-11-01 21:25:45 +05:30 committed by GitHub
parent 48aa4c4a01
commit f89d3a9ec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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