Big O Gym › Problem

Big O Quiz: Linked List Head Insert

What is the time complexity of inserting a node at the head of a singly linked list?

Concept: constant-time pointer manipulation

Allocate the new node, point its `next` at the current head, then update the head pointer to the new node. No traversal, **O(1)**. The contrast with arrays - where head insertion is O(n) due to shifting - is one of the main reasons linked lists exist.

More Big O practice problems · Today's daily problem