DSA Basics: Singly Linked List

Learn nodes, head pointers, next links, traversal, insertion, and deletion in a singly linked list.

Back to Learn DSA

A singly linked list is a chain of nodes.

Each node stores a value and a pointer to the next node.

head -> [12 | next] -> [24 | next] -> [36 | null]

Why linked lists exist

Arrays store values next to each other in memory. Linked lists connect values through references.

That means a linked list can insert or remove nodes without shifting every later value, but it cannot jump directly to index 20.

Core operations

Traversal

function printList(head) {
	let current = head;

	while (current !== null) {
		console.log(current.value);
		current = current.next;
	}
}

Common mistakes

Complexity

Use the visualizer below to move through a linked list one node at a time.

Interactive walkthrough

Linked List Traversal

Move node by node through a singly linked list.