Linked lists are a sequential data structure like lists, but they store data in a different way. Lists store data sequentially in the computer’s memory. Linked lists track the internal memory address of the data so values can be stored anywhere in memory.
The benefit of storing the memory address is that linked lists can insert or delete data in constant time, whereas a list would require linear time. The drawback is that linked lists do not have index access, so searching and accessing values are linear time operations.
The key to understanding linked lists lies in the manipulation of the property
.next, where a node references the following node in the linked list.
All the code from this lesson is available in the text editor. Play around by making some linked lists.