Skip to content

M. Nguyen - Linked List#45

Open
melissa-nguyen wants to merge 3 commits intoAda-C15:masterfrom
melissa-nguyen:master
Open

M. Nguyen - Linked List#45
melissa-nguyen wants to merge 3 commits intoAda-C15:masterfrom
melissa-nguyen:master

Conversation

@melissa-nguyen
Copy link
Copy Markdown

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
Copy Markdown

@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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread linked_list/linked_list.py Outdated
current = self.head

while current.next:
current.next
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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