Member-only story
Data Structures — Linked Lists
Linked Lists have a very special place in my heart. I struggled to get onboard with Data Structures, and for some reason Linked Lists (or LL for short ) was my gateway to pushing through to the other side.
A LL is a data structure with Nodes connected to each other with next pointers within the node. They can be singly connected: much like a train car that you can only walk from the conductor car to the caboose. This is the next pointer going one direction. Or doubly linked: with each node containing pointers to the following node via a next key and a prior node key. The Linked List is an object. The Nodes are objects. Next and Prior are pointers. Data is whatever you want to store.
The Node contains two properties: data — what we’re storing & next — points to the following node, or if it’s the last node in the list contains null. For a doubly linked list, it would have another pointer to the past node in the sequence.
Much like we incremented the front variable in Queue, a Linked List will do the same with the head pointer.
head — the start of our list. When you make the first node, set this var to that instance!
data — whatever goodness you’re storing.
tail — default at null. You know you’ve located the last node while traversing the existing ones.
This is a really great reference that put pointers into perspective, and it does make LL easier to comprehend. And this is a short and sweet video.