Update paths and actually add files

This commit is contained in:
2026-02-08 17:06:29 -08:00
parent e8ebecbd3e
commit 9d20401d30
8 changed files with 308 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
class Node:
next_node = None
def __init__(self, value):
self.value = value
# Homework:
# Make a linked list class with the functions:
# - append(node): add a node to the end of the list
# - insert(node, index): add a node to the middle of the list
# - remove(index): remove the first matching node from the list
class LinkedList:
head = None
tail = None
def append(Llist, thing):
if Llist.head==None:
Llist.head=Node(value=thing)
Llist.tail=Llist.head
return
Llist.tail.nextNode=Node(value=thing)
Llist.tail=Llist.tail.nextNode
list1=LinkedList()
append(list1, 'hi')
append(list1, 'hi again')
append(list1, 'why am I saying hi so many times?')
print(list1.head.value)
print(list1.head.nextNode.value)
print(list1.head.nextNode.nextNode.value)