Linked lists

Nodes hold a value and pointer(s) to neighbours. Switch between singly, doubly, and circular lists, then search, insert, and remove.

Data structures Beginner+ Singly · Doubly · Circular ~12 min
The idea

Nodes and links

A linked list stores values in nodes. Each node points to the next one. The list starts at head. Unlike an array, you walk links instead of jumping by index.

Singly lists have only a next pointer. Doubly lists also keep prev, so you can walk both ways. Circular lists connect the last node back to the head — there is no None at the end.

TipInsert and remove rewrite a few pointers. Search always starts at head and follows next.
IdeaSingly node
node.pyPython
class Node:
    def __init__(self, value):
        self.value = value
        self.next = None
        # doubly also: self.prev = None

Circular singly: the last node’s next points at head.

Interactive

Run the simulation

Each tab walks search, insert, and remove on that list type.

Step 0 / 0
demo.pyPython
List + variablesdemo
Ready
Shortcuts: Space play/pause · → step · ← back · R reset
Try it yourself

Search, insert, and remove

Pick a list type, then use the syllabus operations on your own values.

Ready
List is empty. Enter a value and press Insert.
Remember

Linked-list mental model

Pointers define the structure — change a few links and the list changes.

Singly

One-way next

Cheap forward walks. Going backward means starting over from head.

Doubly

prev and next

Two-way travel. Remove can rewire both neighbours without a second scan.

Circular

Last links to head

No None tail. Stop a search when you return to head, or you’ll loop forever.