added insert_tail function

This commit is contained in:
2026-03-13 07:45:47 -04:00
parent edfb6fc61e
commit 48d9b9be73

View File

@@ -75,7 +75,17 @@ class LinkedList[T]:
## YOUR CODE HERE ## ## YOUR CODE HERE ##
pass new_node = Node(value)
if self.head is None:
self.head = new_node
else:
current = self.head
while current.get_next() is not None:
current = current.get_next()
current.set_next(new_node)
self.size += 1
def remove_head(self) -> T: def remove_head(self) -> T:
''' removes the first Node in the linked list, returning the data item ''' removes the first Node in the linked list, returning the data item