-
Notifications
You must be signed in to change notification settings - Fork 68
Al Leonard - Linked List #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Al, overall nice work you hit the learning goals here, except you never tried working out the time/space complexity. I do suggest you try that as it's good practice.
Otherwise I only made some suggestions for drying up the code a bit. Let me know if you have questions.
if current == None: | ||
return False | ||
while current: | ||
if current.value == value: | ||
return True | ||
current = current.next | ||
notTrue = True | ||
if notTrue == True: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified
if current == None: | |
return False | |
while current: | |
if current.value == value: | |
return True | |
current = current.next | |
notTrue = True | |
if notTrue == True: | |
return False | |
if current == None: | |
return False | |
while current: | |
if current.value == value: | |
return True | |
current = current.next | |
return False |
if node_count: | ||
return node_count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if node_count: | |
return node_count | |
return node_count | |
@@ -9,67 +9,149 @@ def __init__(self, value, next_node = None): | |||
# Defines the singly linked list | |||
class LinkedList: | |||
def __init__(self): | |||
self.head = None # keep the head private. Not accessible outside this class | |||
self.head = None # keep the head private. Not accessible outside this class | |||
self.tail = None # keep track of the tail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice you're not using this.
Thanks for looking at my Linked List answers!