View on GitHub

reading-notes

Observations and questions from reading assignments.

Linked Lists

Home

Definitions

Traversing a linked list can be accomplished by having the current node reference the next node as long as the next node is not null. This is typically done inside a while loop.

To add a node we have to replace the current Head of the linked list with the new node, without losing the reference to the next node in the list.

Adding Nodes

Regardless of the number of Nodes, adding to the head will always be a O(1) time and space because it takes the same amount of time to add a new node to the beginning of the list, and no additional resources are being used.

Big O for Add

Sources

Terminology