Skip to content

NW | 26-SDC-Mar | TzeMing Ho | Sprint 2 | implement_linked_list#168

Open
TzeMingHo wants to merge 2 commits into
CodeYourFuture:mainfrom
TzeMingHo:coursework/implement_linked_list
Open

NW | 26-SDC-Mar | TzeMing Ho | Sprint 2 | implement_linked_list#168
TzeMingHo wants to merge 2 commits into
CodeYourFuture:mainfrom
TzeMingHo:coursework/implement_linked_list

Conversation

@TzeMingHo

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

Changelist

  1. Created a class Node
  2. Created a class LinkedList
  3. Added methods: push_head, pop_tail, remove, and push_tail

@TzeMingHo TzeMingHo 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 Jun 16, 2026
self.tail = new_tail
return val

def remove(self, Node):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Python naming convention for parameters/variables is lower snake case

new_next = Node.next

if self.head == Node and self.tail == Node:
Node.value = 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 clear the value of the removed node?
If it is needed, why not do the same when the removed node is not the only node in the linked list?

new_next.previous = None
self.head = new_next
elif self.tail == Node:
self.pop_tail()

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 writing the "remove tail" code in this function, and then use remove() in pop_tail().

  • Have all the remove logic in one place.

Comment on lines +63 to +64
Node.previous = None
Node.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 probably factor out these two lines of code.

@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 Jun 16, 2026
@TzeMingHo TzeMingHo 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 Jun 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.

Changes look good.

Code could probably use some internal documentation.

Comment on lines +28 to +34
return None

return self.remove(self.tail)

def remove(self, node):
if self.head == None and self.tail == None:
return

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 use the same syntax to return None.

@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 Jun 18, 2026
@cjyuan

cjyuan commented Jun 18, 2026

Copy link
Copy Markdown

Forgot to suggest researching this

When defining a class, how to use __slots__ to restrict which attributes its instance can have in order to reduce per-instance memory usage?

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.

2 participants