LearnFrenzy
Sign in Take a free test

Data Structures in Java · Data Structures in Java MCQ · Question 2

Inserting at the head of a singly linked list Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links