Linked lists in a nutshell
A linked list is a linear data structure that represents a sequence of nodes. The first node is commonly referred to as the head, while the last node is commonly referred to as the tail. When each node points to the next node, we have a singly linked list, as shown in the following diagram:
When each node points to the next node and to the previous node, we have a doubly linked list, as shown in the following diagram:
Let's consider a singly linked list. If the tail points to the head, then we have a circular singly linked list. Alternatively, let's consider a doubly linked list. If the tail points to the head and the head points to the tail, then we have a circular doubly linked list.
In a singly linked list, a node holds the data (for example, an integer or an object) and the pointer to the next node. The following...