Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

melissa-nguyen
Copy link

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.

Copy link

@CheezItMan CheezItMan left a 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!

Comment on lines +16 to 18
# Time Complexity: 0(1)
# Space Complexity: 0(1)
def get_first(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +27 to 29
# Time Complexity: 0(1)
# Space Complexity: 0(n)
def add_first(self, value):

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.

Comment on lines +35 to 37
# Time Complexity: 0(n)
# Space Complexity: 0(1)
def search(self, value):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +49 to 51
# Time Complexity: 0(n)
# Space Complexity: 0(1)
def length(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +67 to 69
# Time Complexity: 0(n)
# Space Complexity: 0(1)
def get_at_index(self, index):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

current = self.head

while current.next:
current.next

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

Suggested change
current.next
current = current.next

Comment on lines +91 to 93
# Time Complexity: 0(n)
# Space Complexity: 0(1)
def get_last(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +140 to 142
# Time Complexity: 0(n)
# Space Complexity: 0(1)
def delete(self, value):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +164 to 166
# Time Complexity: 0(n)
# Space Complexity: 0(1)
def visit(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +180 to 182
# Time Complexity: 0(1)
# Space Complexity: 0(n)
def reverse(self):

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants