- In a singly linked list, what is the time complexity to insert a node at the beginning?
A
O(1)
B
O(n)
C
O(log n)
D
O(n²)
Answer and explanation
Correct Answer: A — O(1)
Inserting at the beginning takes constant time O(1) as we only update the head pointer.
