A linked list in C++ is a linear data structure used to store data in non-contiguous memory locations. Unlike arrays, linked lists store elements dynamically and connect them using pointers.
- Linked lists store elements dynamically in memory.
- Each element is called a node.
- Nodes are connected using pointers.
Linked List Representation
A linked list is represented by a pointer called head, which points to the first node of the list. Each node typically contains:
- Data: Stores the actual value.
- Next Pointer: Stores the address of the next node.
Node Structure:
struct Node
{
int data;
Node* next;
};
Explanation
- data stores the value of the node.
- next stores the address of the next node.
- The last node points to NULL.
Types of Linked Lists
Based on their structure, linked lists are classified into the following types:
1. Singly Linked List in C++
A Singly linked List is the simplest form of linked list. Each node contains data and a pointer to the next node. The last node's next pointer points to NULL, indicating the end of the list.

Singly Linked List Representation
Singly linked list can be represented as a pointer to the first node, where each node contains:
- Data: Actual information is stored.
- Next: Pointer to the next node.
struct Node {
// Data field - can be of
// any type and count
int data;
// Pointer to the next node
struct Node* next;
}
Basic Operations for Singly Linked List
Operation | Operation Type | Description | Time Complexity | Space Complexity |
|---|---|---|---|---|
Insertion | At Beginning | Insert a new node at the start of a linked list. | O (1) | O (1) |
| At the End | Insert a new node at the end of the linked list. | O (N) | O (1) | |
| At Specific Position | Insert a new node at a specific position in a linked list. | O (N) | O (1) | |
Deletion | From Beginning | Delete a node from the start of a linked list | O (1) | O (1) |
| From the End | Delete a node at the end of a linked list. | O (N) | O (1) | |
| A Specific Node | Delete a node from a specific position of a linked list. | O (N) | O (1) | |
Traversal | Traverse the linked list from start to end. | O (N) | O (1) | |
2. Doubly Linked List in C++
A doubly linked list is an extension of a singly linked list where each node contains pointers to both the next and previous nodes. This allows traversal in both forward and backward directions.

Doubly Linked List Representation
Doubly linked list can be represented as pointer to the first node where each node contains:
- Data: Actual information is stored.
- Next: Pointer stores the address of next node.
- prev: Pointer stores the address of previous node.
struct Node {
// Data field - can be of any type and count
int data;
// Pointer to the next node
struct Node* next;
// Pointer to the previous node
struct Node* prev;
}
Basic Operations for Doubly Linked List
Operation | Operation Type | Description | Time Complexity | Space Complexity |
|---|---|---|---|---|
Insertion | At Beginning | Insert a new node at the start of a linked list. | O (1) | O (1) |
| At the End | Insert a new node at the end of the linked list. | O (N) | O (1) | |
| At Specific Position | Insert a new node at a specific position in a linked list. | O (N) | O (1) | |
Deletion | From Beginning | Delete a node from the start of a linked list | O (1) | O (1) |
| From the End | Delete a node at the end of a linked list. | O (N) | O (1) | |
| A Specific Node | Delete a node from a specific position of a linked list. | O (N) | O (1) | |
Traversal | Traverse the linked list from start to end or vice versa. | O (N) | O (1) | |
3. Circular Linked List in C++
A circular linked list is similar to a singly linked list, but the last node points back to the first node instead of pointing to NULL. This creates a circular structure.

Circular Linked List Representation
Circular linked list can be represented as pointer to the first node where each node contains:
- Data: Actual information is stored.
- Next: Pointer to the next node and last node Next is pointed to the first node of the linked list.
// Structure to represent the circular linked list
struct Node {
// Data field - can be of any type and count
int data;
// Pointer to the next node
struct Node* next;
}
Basic Operations for Circular Linked List
Operation | Operation Type | Description | Time Complexity | Space Complexity |
|---|---|---|---|---|
Insertion | At Beginning | Insert a new node at the start of a linked list. | O (N) | O (1) |
| At the End | Insert a new node at the end of the linked list. | O (N) | O (1) | |
| At Specific Position | Insert a new node at a specific position in a linked list. | O (N) | O (1) | |
Deletion | From Beginning | Delete a node from the start of a linked list | O (N) | O (1) |
| From the End | Delete a node at the end of a linked list. | O (N) | O (1) | |
| A Specific Node | Delete a node from a specific position of a linked list. | O (N) | O (1) | |
Traversal | Traverse the linked list from start to end or vice versa. | O (N) | O (1) | |
Applications of Linked Lists
Following are some common applications of the linked list data structure:
- In dynamic memory allocation linked lists are used to keep track of free and allocated memory blocks.
- Linked lists are used in text editors to implement undo and redo operations.
- Linked lists are used to implement adjacency lists for the graph data structures.
- Linked lists are also used to implement fundamental data structures like stack and queue.
Advantages of Linked List
Advantages of linked list are mentioned below:
- Inserting and deleting node is efficient because no need to shifting like in array.
- Linked lists have dynamic size, which allows them to grow or shrink during runtime.
- Memory is utilized more efficiently as linked lists do not require a pre-allocated size, reducing wasted space.
- Efficient for those operations where we need large or frequently changing datasets.
- Linked list used non-contiguous memory blocks, so it is useful for those application where memory is needed.
Limitations of Linked List
Despite its flexibility and dynamic nature, a linked list has some limitations:
- No Direct Access: Elements cannot be accessed directly using an index. To reach a specific node, the list must be traversed from the beginning.
- Additional Memory Requirement: Each node requires extra memory to store one or more pointer variables.
- Sequential Searching: Searching for an element can be slower because nodes must be visited one by one.
- Complex Implementation: Linked lists are generally more complex to implement and maintain compared to arrays.