Skip to content

linked list

A linked list is a linear data structure in which each element points to the next, so the elements form a chain rather than sitting in one contiguous block of memory. Each element, called a node, holds a value and a reference to the following node:

A Head pointer leads to a row of nodes, each holding a value and a next pointer, with the last node's next pointing to None.
A Chain of Nodes Joined by References

Because nodes are joined by references, inserting or removing an element is cheap once its position is known. Only a couple of references change, an O(1) operation. The trade-off is that reaching the element at a given index means walking the chain from the start, an O(n) operation, since there is no direct indexing the way a contiguous array allows.

Click any node in the singly linked list below to see how many references you follow from the head to reach it, then insert or delete to watch how few references change:

Interactive diagram — enable JavaScript to view.

Variants include the singly linked list, the doubly linked list whose nodes also point backward, and the circular linked list whose last node points back to the first. Linked lists also underpin other structures, such as stacks, queues, and the adjacency lists used to represent a graph.

Tutorial

Linked Lists in Python: An Introduction

In this article, you'll learn what linked lists are and when to use them, such as when you want to implement queues, stacks, or graphs. You'll also learn how to use collections.deque to improve the performance of your linked lists and how to implement linked lists in your own projects.

intermediate data-structures

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated June 23, 2026 • Reviewed by Leodanis Pozo Ramos