Skip to content

London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a linked list - #206

Open
Zobeir-Rigi wants to merge 3 commits into
CodeYourFuture:mainfrom
Zobeir-Rigi:implement-linked-list
Open

London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a linked list#206
Zobeir-Rigi wants to merge 3 commits into
CodeYourFuture:mainfrom
Zobeir-Rigi:implement-linked-list

Conversation

@Zobeir-Rigi

Copy link
Copy Markdown
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

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.

@Zobeir-Rigi Zobeir-Rigi added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Complexity The name of the module. labels Jul 6, 2026
Comment on lines +1 to +5
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.previous = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

May I suggest exploring the use of __slots__ to reduce memory usage?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not just call remove()?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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 cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 9, 2026
@cjyuan

cjyuan commented Jul 15, 2026

Copy link
Copy Markdown

Looks good.

Note: I assume this PR is ready to be reviewed.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants