← Back

Linked List Simulator

What is a Singly Linked List?

A singly linked list is a sequence of nodes. Each node stores data and a reference to the next node. Nodes do not need to occupy contiguous memory locations.

Add/remove headO(1)
Access/searchO(n)
Add/remove tailO(n)*
ReverseO(n)

*O(1) tail insertion is possible when a tail reference is maintained.

Edit the linked list

350 ms

Use the controls to modify or inspect the list.

Current operationIdle
Nodes visited0
Comparisons / changes0
Complexity

Linked list concepts

Node structure

Each node contains a data field and a next field. The final next field stores NULL.

Head operations

Adding or removing the head changes only the head reference, so both operations take O(1).

Traversal

There is no direct index access. Reaching a position requires following links from HEAD, which takes O(n) in the worst case.

Reverse

Reversal changes every next reference so that the former tail becomes the new head. It takes O(n) time and O(1) auxiliary space.

Typical time complexities

OperationTimeReason
Add/remove headO(1)Only the head reference changes.
Access/searchO(n)Links are followed from HEAD.
Add/remove tailO(n)A basic singly linked list must find the last or previous node.
Insert/delete at known nodeO(1)Only nearby references change.
ReverseO(n)Every next reference changes once.
Bubble SortO(n²)Adjacent values are repeatedly compared.