A linked list is a data structure that can be used to store data. It is is essentially a collection of nodes. Each node in a linked list contains the data object to be stored as well as a reference (link) to the next node in the list. If the node is the last in the list then it’s next node is set to nothing. The resulting structure conceptually resembles a chain. The head node in the linked list is stored in the list itself.
Here’s an image depicting what a linked list looks like conceptually:
Advantages:
Disadvantages:
Singly A singly linked list is what has been described. It is a linked list in which each node contains a data element as well as a reference to the next node. This allows us to iterate forwards through the linked list, but not backwards.
Doubly A doubly linked list is a linked list in which each node contains a data element as well as a reference to both the next node and the previous node. This gives us the extra ability to iterate backwards (as well as forwards) through the linked list. This extra ability comes with the cost of the list taking up more space in memory. The list will take up more space in memory because each node in the list now requires an extra pointer.