Skip to content

Birmingham | 26-Jul SDC | Merve Reis | Sprint 2 | Implement linked list - #241

Open
mervereis wants to merge 3 commits into
CodeYourFuture:mainfrom
mervereis:sprint2-implement-link-list
Open

mervereis wants to merge 3 commits into
CodeYourFuture:mainfrom
mervereis:sprint2-implement-link-list

Conversation

@mervereis

@mervereis mervereis commented Oct 12, 2026 •

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • 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

Task code

CYF-1180

Changelist

Implemented a doubly linked list in Python with O(1) operations for adding elements at the head, removing elements from the tail, and removing specific elements using node handles.

@mervereis mervereis added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 12, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could consider adding type hints to each method to clearly specify the types of its parameters and return value.

Comment on lines +2 to +6
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.

Thanks for the suggestion! I added type hints and used slots for the node attributes to reduce memory usage. @cjyuan

Comment on lines +31 to +42
old_tail = self.tail
value = old_tail.value

if self.head is self.tail:
self.head = None
self.tail = None
else:
self.tail = old_tail.previous
self.tail.next = None

old_tail.next = None
old_tail.previous = None

@cjyuan cjyuan Oct 13, 2026 •

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 delegate the node removing task to remove()? Less code to maintain.

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.

Good suggestion. I updated pop_tail() to call remove(old_tail) so the unlinking logic is kept in one place. @cjyuan

@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 Oct 13, 2026
@mervereis mervereis added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 15, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changes look good.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants