How to use the Linked List Visualizer
- 1. Pick a list typeSingly, doubly or circular singly linked.
- 2. Enter a value and positionThe position is a 0-based index.
- 3. Run an operationSee the new list and what the operation cost.
Linked lists vs arrays
A linked list stores each value in a node with a pointer to the next node. A doubly linked list also points back to the previous node, and a circular list's last node points back to the head.
- Insert or delete at the head: O(1); just change a pointer or two.
- Insert at the tail: O(1) if you keep a tail pointer, otherwise O(n) to walk there.
- Access by index or search: O(n), because you must follow the links one by one. An array does indexing in O(1).
- Reverse: O(n) time and O(1) extra space, by flipping each next pointer as you walk.
Linked lists shine when you insert and remove a lot in the middle of a sequence you are already walking through, as in LRU caches, undo history and adjacency lists. For most other jobs, arrays and dynamic lists are faster because their memory is contiguous.
Worked example
The list starts as 10 → 20 → 30. Insert 25 at position 2: the tool walks 2 nodes and links 25 in, giving 10 → 20 → 25 → 30, at a cost of O(n) to walk and O(1) to link. Then:
- Search 30: found at index 3 after 4 steps.
- Delete value 20: 10 → 25 → 30.
- Reverse: 30 → 25 → 10.
Switch to Doubly linked and the arrows become ⇄, and tail inserts become O(1). Switch to Circular and the last node shows "back to head". The recent-operations list keeps the last 12 steps, so you can replay a sequence from a textbook question and compare.
Frequently asked questions
What is the difference between delete value and delete at position?
Delete value removes the first node holding that value; delete at position removes the node at that index.
Why is there no index in a real linked list?
Nodes don't know their position. The [i] labels are only shown to help you follow along.
How do I reverse a linked list in code?
Keep three pointers, prev, curr and next, and walk the list setting curr.next = prev each step.
Is the linked list visualizer free to use?
Yes, the linked list visualizer is free and costs nothing. Your first operation shows a short form for your name and WhatsApp number one time; once that's done, this tool and every other Uncodemy tool open with no form.