CS230 Lecture Notes - Lecture 13: Linked List, While Loop
Document Summary
Structure in which there"s a head, each item has a value and a pointer to the next item. There is a head reference and a tail reference. To append a node to the end of the linked list, simply have the current tail reference the new item then have the new item be referenced as the tail node. If the list is empty then the head and tail will just reference the node that is about to be appended. To remove the last node, traverse through the linked list and make the 2nd last item reference none and have the tail reference that item. To remove any nodes in the middle, traverse through the linked list until you found the item that you want to remove, then make the item before it reference the item after it. To remove the first node, make the head reference the second item in the list and make the first item reference none.