Reading-Notes

Linked List Notes

Imagine you have a list of items that you want to store in your computer’s memory. A linked list is a data structure that allows you to store and organize this list efficiently. In a linked list, each item is represented by a node, and each node contains two main components: the data and a reference to the next node in the list.

For example we have a linked list for fruit, we would have each node point to the next, so it contains the data, and then the neighbor node. When we get to our last node, we would set the next one to null, so it knows we’re at the end of our list. This lets our data not be structured.

To create the first node, we need to define both the data and the reference to the next node. Let’s say the first fruit in our list is an apple. So, we create a node with the data “apple” and set the next reference to null since it’s the only node in the list.

If we wanted to create another Node, we would define the data and reference it back to the first node.

Ex:

Node 1: Data: “apple” Next: Node 2

Node 2: Data: “banana” Next: null

References

Big O Notes Linked List Linked List Part 1 Linked List Part 2