PublicSoftTools

Linked List Visualizer

Build and manipulate a singly linked list step by step. Insert at head, tail, or any index; delete nodes from the front, back, or by value; search for elements. Colour-coded animations show exactly how pointers change. No signup, runs entirely in your browser.

10
•→
HEAD
20
•→
30
•→
40
•→
TAIL
NULL
Length: 4Head: 10Tail: 40
Operations
No operations yet

Linked List Concepts to Practise

Head and tail pointers

Most linked list implementations maintain both a head and tail pointer. This makes insertHead and insertTail O(1) without traversal. Notice how the HEAD and TAIL labels update as you insert and delete.

Finding mid-point

The slow/fast pointer technique finds the middle node in one pass: slow advances one step, fast advances two. When fast reaches NULL, slow is at the middle. Use this for merge sort on linked lists.

Reversing a list

To reverse a linked list iteratively, keep track of previous, current, and next pointers. Walk through the list reassigning each node's next to the previous node — O(n) time, O(1) space.

Detecting cycles

Floyd's cycle detection uses slow and fast pointers. If the list has a cycle, fast eventually laps slow and they meet. If fast reaches NULL, there is no cycle. Time: O(n), space: O(1).

Frequently Asked Questions

What is a singly linked list?

A singly linked list is a linear data structure where each node holds a value and a pointer to the next node. Unlike arrays, nodes do not need to be stored contiguously in memory — each node points to the next via a reference.

What is the time complexity of insertions?

Insert at head or tail is O(1) if you maintain a head and tail pointer. Insert at an arbitrary index is O(n) because you must traverse the list to reach that position. Deletion follows the same pattern.

When should I use a linked list instead of an array?

Use a linked list when you frequently insert or delete at the front or middle of a large list, and do not need random access by index. Arrays are better when you need fast index access (O(1)) and predictable memory layout for cache performance.

What do the colours mean?

Green highlight means a newly inserted node. Blue highlight means a successfully found node (search). Red highlight means a node about to be removed from the list.

Can I insert at a specific position?

Yes. Use the "Insert at index" operation and enter the 0-based index. Index 0 is equivalent to insertHead. If the index equals the list length, the node is appended to the tail.

Is my data stored?

No. All operations are local to your browser session. Nothing is sent to any server.