Question 2
Back to Exercise
What is the time complexity of inserting a new node at the head of a singly linked list?
- A O(1) Correct
- B O(n)
- C O(log n)
- D O(n²)
Correct Answer: Option A
Create the node, point its next at the old head and make it the new head – no traversal or shifting.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!