Time and Space Complexity of Linked List (original) (raw)

Last Updated : 23 Jul, 2025

A linked list is a fundamental data structure in computer science and programming. It is a collection of **nodes where each node contains a **data field and a reference (**link) to the next node in the sequence. The last node in the list points to **null, indicating the end of the list. Knowing the time and space complexity of linked lists is important for improving algorithms and applications that use them. In this article, we are going to take a look at the complexity analysis of common operations of linked lists.

Complexity Analysis of different Operations on Linked List:

Table of Content

Below table represents the time and space complexities for various operations on a linked list:

Operation Time Complexity Auxiliary Space Explanation
Insertion at Beginning O(1) O(1) Constant-time pointer updates.
Insertion at End O(n) O(1) Traversal required to find the last node.
Insertion at Position O(n) O(1) Traversal to the desired position, then constant-time pointer updates.
Deletion at Beginning O(1) O(1) Constant-time pointer update.
Deletion at End O(n) O(1) Traversal required to find the second last node.
Deletion at Position O(n) O(1) Traversal to the desired position, then constant-time pointer updates.
Searching in Linked list O(n) O(1) Traversal through the list to find the desired value.

Let's look at time and auxiliary space complexity of each of these above operations in detail.

Complexity Analysis of Insertion at the Beginning of Linked List

These operations involve only a few pointer manipulations, which take constant time regardless of the size of the list.

Complexity Analysis of Insertion at the End of Linked List

The traversal dominates the time complexity, making it linear in relation to the number of nodes.

Complexity Analysis of Insertion at a Specific Position of Linked List

The traversal step dominates the time complexity.

Complexity Analysis of Deletion at the Beginning of Linked List

This is a constant-time operation as it only involves updating a single pointer.

Complexity Analysis of Deletion at the End of Linked List

The traversal step dominates the time complexity.

Complexity Analysis of Deletion at a Specific Position of Linked List

The traversal step dominates the time complexity.

Complexity Analysis of Search for a Value of Linked List

In the worst case, the entire list must be traversed, making the time complexity linear.