Skip to content

London | 25-SDC-Nov | Aida Eslamimoghadam | Sprint 2 | Implement a linked list in python#146

Closed
aydaeslami wants to merge 3 commits into
CodeYourFuture:mainfrom
aydaeslami:Implement-a-linked-list-in-Python
Closed

London | 25-SDC-Nov | Aida Eslamimoghadam | Sprint 2 | Implement a linked list in python#146
aydaeslami wants to merge 3 commits into
CodeYourFuture:mainfrom
aydaeslami:Implement-a-linked-list-in-Python

Conversation

@aydaeslami

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

Changelist

Implemented a doubly linked list supporting push_head, pop_tail, and remove operations in O(1) time.

@aydaeslami aydaeslami 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. labels Mar 1, 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.

The code in linked_list_test.py expects both .next and .previous properties of the removed node to be assigned None. Currently your implementation could not pass the tests.

Note: Do you know the why it is a good practice to assign .next and .previous of the removed node to None?

Comment on lines +31 to +36
if self.tail.previous:
self.tail = self.tail.previous
self.tail.next = None
else:
self.head = None
self.tail = 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.

@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 Mar 2, 2026
@aydaeslami

aydaeslami commented Jun 22, 2026

Copy link
Copy Markdown
Author

Thanks @cjyuan, for your helpful feedback and suggestions.

My tests were passing even without setting node.previous and node.next to None, so I didn't realize this issue was there. I've now added those lines and updated the implementation accordingly.

Do you know the why it is a good practice to assign .next and .previous of the removed node to None

I think it's a good practice because if we still have access to the removed node, we could accidentally reach other nodes through its .next and .previous links. Setting them to None makes it clear that the node is no longer part of the list and helps avoid mistakes.

Thanks again for taking the time to review it and point it out.

@cjyuan

cjyuan commented Jun 22, 2026

Copy link
Copy Markdown

Changes look good.

I forgot to suggest looking into __slots__ during my previous review. Could you spend a little time reading up on it and how it can be used in class design? No changes are expected; this is just for learning purposes.

@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 Jun 22, 2026
@illicitonion

Copy link
Copy Markdown
Member

Closing PR because the SDC run has finished. Feel free to re-open if you're still working on it.

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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants