-
Notifications
You must be signed in to change notification settings - Fork 68
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
M. Nguyen - Linked List #45
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.
Melissa, it's normal to struggle here. If it was easy, anyone would do this for a living. I did find the small typo that was causing tests to hang. Let me know if you have questions.
You did hit the main learning objectives here. Overall, well done!
# Time Complexity: 0(1) | ||
# Space Complexity: 0(1) | ||
def get_first(self): |
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.
👍
# Time Complexity: 0(1) | ||
# Space Complexity: 0(n) | ||
def add_first(self, value): |
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.
👍 However the space complexity is O(1) because you're only ever adding 1 node.
# Time Complexity: 0(n) | ||
# Space Complexity: 0(1) | ||
def search(self, value): |
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.
👍
# Time Complexity: 0(n) | ||
# Space Complexity: 0(1) | ||
def length(self): |
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.
👍
# Time Complexity: 0(n) | ||
# Space Complexity: 0(1) | ||
def get_at_index(self, index): |
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.
👍
linked_list/linked_list.py
Outdated
current = self.head | ||
|
||
while current.next: | ||
current.next |
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.
This is why the tests hang
current.next | |
current = current.next | |
# Time Complexity: 0(n) | ||
# Space Complexity: 0(1) | ||
def get_last(self): |
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.
👍
# Time Complexity: 0(n) | ||
# Space Complexity: 0(1) | ||
def delete(self, value): |
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.
👍
# Time Complexity: 0(n) | ||
# Space Complexity: 0(1) | ||
def visit(self): |
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.
👍
# Time Complexity: 0(1) | ||
# Space Complexity: 0(n) | ||
def reverse(self): |
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.
👍 However the time complexity is O(n) and space complexity is O(1)
Chris,
I struggled with passing the test, test_add_last_increases_length_and_new_item_appears_at_back_of_list(list) - I couldn't figure out why it wasn't passing and had trouble debugging.