M. Nguyen - Linked List#45
Open
melissa-nguyen wants to merge 3 commits intoAda-C15:masterfrom
Open
Conversation
CheezItMan
reviewed
Oct 20, 2021
CheezItMan
left a comment
There was a problem hiding this comment.
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): |
Comment on lines
+27
to
29
| # Time Complexity: 0(1) | ||
| # Space Complexity: 0(n) | ||
| def add_first(self, value): |
There was a problem hiding this comment.
👍 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): |
Comment on lines
+49
to
51
| # Time Complexity: 0(n) | ||
| # Space Complexity: 0(1) | ||
| def length(self): |
Comment on lines
+67
to
69
| # Time Complexity: 0(n) | ||
| # Space Complexity: 0(1) | ||
| def get_at_index(self, index): |
| current = self.head | ||
|
|
||
| while current.next: | ||
| current.next |
There was a problem hiding this comment.
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): |
Comment on lines
+140
to
142
| # Time Complexity: 0(n) | ||
| # Space Complexity: 0(1) | ||
| def delete(self, value): |
Comment on lines
+164
to
166
| # Time Complexity: 0(n) | ||
| # Space Complexity: 0(1) | ||
| def visit(self): |
Comment on lines
+180
to
182
| # Time Complexity: 0(1) | ||
| # Space Complexity: 0(n) | ||
| def reverse(self): |
There was a problem hiding this comment.
👍 However the time complexity is O(n) and space complexity is O(1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.