London | SDC-Nov-25 | Emiliano Uruena | Sprint 2 | Linked List Python#131
London | SDC-Nov-25 | Emiliano Uruena | Sprint 2 | Linked List Python#131Emilianouz wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
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?
| class Node: | ||
| def __init__(self, value): | ||
| self.value = value | ||
| self.prev = None |
There was a problem hiding this comment.
The tests in the linked_list_test.py expect the properties named in certain way.
| if self.head == self.tail: # if only one element | ||
| self.head = None | ||
| self.tail = None | ||
| else: | ||
| self.tail = self.tail.prev # move tail back | ||
| self.tail.next = None # remove old tail connection |
There was a problem hiding this comment.
Could consider delegating the node removing task to self.remove() -- less code to maintain.
Renamed for test, and updated references.
To prevent accidental references. Thank you. |
|
Changes look good. |
Self checklist
Changelist
LinkedList implementation with double linked list.