Learnearn.uk » A Level Computer Science Home » Linked List

At its simplest, a linked list is a data structure that contains a series of nodes, where each node is linked to the next node in the list. Each node contains two main parts: the actual data that we want to store, and a pointer to the next node in the list.

Linked lists are dynamic data structures, which means that we can add or remove nodes from the list at any time. This makes them very flexible and efficient for certain types of operations, like inserting or deleting elements.

## SLL

A singly linked list is a data structure that consists of a sequence of nodes, where each node stores a piece of data and a pointer to the next node in the list. In other words, each node contains two parts: the actual data that we want to store and a reference (or pointer) to the next node in the list.

## DLL

A doubly linked list is a type of data structure that consists of a sequence of nodes, where each node stores a piece of data and two pointers: one to the next node in the list, and one to the previous node in the list. In other words, each node contains three parts: the actual data that we want to store, a pointer to the next node in the list, and a pointer to the previous node in the list.

This extra pointer to the previous node makes doubly linked lists more versatile than singly linked lists. With a doubly linked list, we can traverse the list in either direction, from the head to the tail or from the tail to the head, making it easier to perform certain types of operations, like searching for a specific element.

## Circular SLL

A circularly linked list is a type of data structure that is similar to a singly linked list, but with one key difference: instead of having the last node point to null (signifying the end of the list), the last node in the list points back to the first node, forming a circle.

This circular structure allows for some interesting properties. For example, we can traverse the list in a loop, continuously visiting each node in the list. Additionally, we no longer need to keep track of the head or tail of the list, since every node in the list can be treated as both the head and the tail.