My personal implementation of a linked list algorithm structure.
A linked list is a series of nodes that contain at least two things:
- a data property that contains the piece of data contained in the node (whether it is an integer, string or other some data object)
- a pointer to another node, whether it is the next node in the linked list, or the previous node in the linked list
The most intuitive data structure is an array. In lower level programming, an array is a sufficiently simple data structure for storing multiple pieces of data but it comes with some downsides. First, you must know ahead of time the amount of memory space or slots that an array will need. Second, an array occupies one continuous block of memory. A linked list, on the other hand, is just a series of nodes that point to each other. Therefore, their address in memory don't have to be adjacent to each other. This also gives the added benefit that additional data/nodes can be easily added to the linked list.