Data Structures · Visualization

Linked List: Introduction

Linked List

A linked list is a chain of separate nodes, where each node holds a value and a pointer (link) to the next node. Time: O(1) to access head/tail if tracked, O(n) to access an arbitrary node. Space: O(n).

Big-O: Lookup O(n); insert/delete at head O(1).

Linked List: Introduction

Linked List

A linked list is a chain of separate nodes, where each node holds a value and a pointer (link) to the next node. Unlike an array, the nodes do not have to sit next to each other in memory — they can be scattered anywhere, and the links are what keep them in order. The list starts at a 'head' pointer and ends when a node's next pointer is null.

How Linked List: Introduction Works

  1. Create a node containing a value and a 'next' pointer.
  2. Point the 'next' field to the following node in the chain, or to null if it is the last node.
  3. Keep a 'head' reference pointing to the first node so the list can always be found.
  4. To visit the whole list, start at head and keep following 'next' until you reach null.

Linked List: Introduction Worked Example

Input: Build a list holding 10, 20, 30

  1. Create node(10), node(20), node(30)
  2. node(10).next = node(20)
  3. node(20).next = node(30)
  4. node(30).next = null
  5. head = node(10)

Output: head -> 10 -> 20 -> 30 -> null

📖 Introduction: this is an overview of the topic, so there's nothing to run here. Pick an operation from the side menu to see a live, step-by-step animation.
Linked List: Introduction
A chain of nodes, each holding a value plus a pointer to the next node — unlike an array, the values are not stored side by side in memory.
12
99
37
5
71
∅
Active / pointers Result null (end) Random pointer
Linked List: Introduction
Press ▶ Run to watch it step by step.
Python · Singly Linked List in Code
class Node:
    def __init__(self, val):
        self.val = val
        self.next = None

class LinkedList:
    def __init__(self):
        self.head = None
# example: intro on [10, 20, 30]

Linked List: Introduction Time & Space Complexity

TimeO(1) to access head/tail if tracked, O(n) to access an arbitrary node
SpaceO(n)

When to Use Linked List: Introduction

  • Implementing stacks, queues, and other structures that need fast front insertion/removal
  • Situations where the size is unknown and frequent insertions/deletions happen in the middle
  • Undo history, music playlists, and browser back/forward chains

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits

Ready for the next step?

See the same ideas in action — visualize the algorithms that operate on these structures, or take a guided course.