London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a linked list - #206
Open
Zobeir-Rigi wants to merge 3 commits into
Open
London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a linked list#206Zobeir-Rigi wants to merge 3 commits into
Zobeir-Rigi wants to merge 3 commits into
Conversation
cjyuan
reviewed
Jul 9, 2026
Comment on lines
+1
to
+5
| class Node: | ||
| def __init__(self, value): | ||
| self.value = value | ||
| self.next = None | ||
| self.previous = None |
There was a problem hiding this comment.
May I suggest exploring the use of __slots__ to reduce memory usage?
Author
There was a problem hiding this comment.
May I suggest exploring the use of
__slots__to reduce memory usage?
Thanks for the suggestion. I wasn't familiar with slots, so I looked into it and learned that it can reduce memory usage by avoiding an instance dictionary for each Node. I've updated the Node class to use slots.
Comment on lines
+32
to
+37
| if self.head == self.tail: | ||
| self.head = None | ||
| self.tail = None | ||
| else: | ||
| self.tail = self.tail.previous | ||
| self.tail.next = None |
Author
There was a problem hiding this comment.
Why not just call
remove()?
The removal logic in pop_tail duplicated behaviour that already existed in remove(). I've refactored pop_tail to reuse remove(), which reduces duplication and keeps the implementation simpler.
|
Looks good. Note: I assume this PR is ready to be reviewed. |
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.
I originally completed all the Sprint 2 exercises in one PR, but the validation expected separate PRs for each issue. This PR contains only the "Implement a linked list in Python" solution.
Implemented the required linked list operations and verified that all tests pass.