Uh oh!
There was an error while loading. Please reload this page.
London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a linked list - #206
London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a linked list#206Zobeir-Rigi wants to merge 3 commits into
Conversation
| 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?
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.
| if self.head == self.tail: | ||
| self.head = None | ||
| self.tail = None | ||
| else: | ||
| self.tail = self.tail.previous | ||
| self.tail.next = None |
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.
cjyuan
commented
Jul 15, 2026
Looks good. Note: I assume this PR is ready to be reviewed. |
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.