Skip to content

WestMidlands | SDC NOV 2025| Sara Tahir | Sprint 2 | Implement a Python Linked List#111

Open
SaraTahir28 wants to merge 3 commits intoCodeYourFuture:mainfrom
SaraTahir28:feature/linkedlist
Open

WestMidlands | SDC NOV 2025| Sara Tahir | Sprint 2 | Implement a Python Linked List#111
SaraTahir28 wants to merge 3 commits intoCodeYourFuture:mainfrom
SaraTahir28:feature/linkedlist

Conversation

@SaraTahir28
Copy link

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

Changelist

  1. I started with implementing a basic linked list first for my own understanding
  2. I added the full implementation of the doubly linked list required for the assignment in second commit
  3. Each node now tracks both next and previous, and the list keeps references to both head and tail so all operations stay O(1).

Questions

I have no Questions. Thanks.

@SaraTahir28 SaraTahir28 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 17, 2026
Copy link

@cjyuan cjyuan left a comment

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?

@@ -0,0 +1,55 @@

#each node should know what comes before it and what come after it
class node:
Copy link

Choose a reason for hiding this comment

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

Why not name the class name in PascalCase?

Copy link
Author

Choose a reason for hiding this comment

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

I have changed that to Node. Thanks

Comment on lines 27 to 29
#Remove last node
def pop_tail(self):
if self.tail is None:
Copy link

Choose a reason for hiding this comment

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

Why not use docstring to describe the method?

Note: The indentation of the comment is a bit off.

Comment on lines 32 to 41
removed = self.tail
#checking for 1 elemt
if self.head == self.tail:
self.head = self.tail = None
return removed.value

#Greater than 1 element, move tailpointer to previos
self.tail = self.tail.previous
self.tail.next = None #cutting link to old tail
return removed.value
Copy link

Choose a reason for hiding this comment

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

Could consider calling remove(removed) -- less code to maintain.

Copy link
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 updated pop_tail() to call remove(removed) so that all pointer‑manipulation logic lives in one place

@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 Feb 27, 2026
@SaraTahir28
Copy link
Author

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

I have researched on how important it is to set .next and .previous to None to maintaine the integrity of the data structures, prevent bugs and make debugging easier because a removed node must not still point into the list.

@SaraTahir28 SaraTahir28 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants