The fact is that, unlike an array
, we don’t need to shift the elements of a singly-linked list
while doing an insertion. Therefore, the insertion time complexity of a singly-linked list is O(1)
.
Imagine that you have a Python list
filled with integer numbers...
my_list = [9, 8, 4, 5, 6]
... and you want to insert the number 3
right after the element 8
.
my_list.insert(2, 3)
The printed result will be:
[9, 8, 3, 4, 5, 6]
When you do an insertion to my_list
, the other elements after the element 3
are all shifted towards the right, so their indexes are changed. As a result, the time complexity to insert an element at a given index is O(n)
.
However, in singly-linked lists
, there are no array elements, but chained nodes
and node values
.

Image source: LeetCode
As the above image shows, the prev
node holds the reference
of the next
node. As @πάντα ῥεῖ stated, "function signatures already take the predecessor node as argument". You can find the previous node in O(n)
time, but while inserting a new node, you just need to change the addresses of connected nodes and that is O(1)
time complexity.