Question DSA-LL-0002
EasyWhat is the time complexity of inserting a node at the head of a singly linked list?
- A.
O(n)
- B.
O(log n)
- C.
Show answer and explanation
Answer: C
Point the new node at the old head and update the head pointer.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Linked Lists question
What is the time complexity of inserting a node at the head of a singly linked list?
O(n)
O(log n)
Answer: C
Point the new node at the old head and update the head pointer.
O(1)
O(n²)