Skip to content

Manchester | 26-SDC-Jun | Fithi Teklom | Sprint 2 | Linked Link in Python - #260

Open
Fithi-Teklom wants to merge 2 commits into
CodeYourFuture:mainfrom
Fithi-Teklom:feature/link-list
Open

Fithi-Teklom wants to merge 2 commits into
CodeYourFuture:mainfrom
Fithi-Teklom:feature/link-list

Conversation

@Fithi-Teklom

Copy link
Copy Markdown

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

Implement doubly linked list operations.

@Fithi-Teklom Fithi-Teklom added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 16, 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 +43 to +52
# If there's only one carriage, the train becomes empty
if self.head == self.tail:
self.head = None
self.tail = None
else:
# Move the tail backwards by one carriage
self.tail = self.tail.previous

# The new last carriage has no carriage after it
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.

Could consider delegating the node removing task to remove() -- less code to maintain.

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.

Thank you for your feedback @cjyuan . So I have
-Added type hints.
-Reused remove() inside pop_tail().
-Added slots to reduce node memory overhead.

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

Excellent work!


def push_head(self, value):
# Make a new carriage
class Node(Generic[T]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of generics! Nice!

Note: I think since Python 3.12, there is a slightly simpler syntax to use generics.

@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. labels Oct 17, 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