Chapter 5 · Simulation

Linked List Simulator

← Chapter 5
Ready.

Linked List Simulator

A singly linked list is a chain of nodes, each holding a value and a next pointer. The only way in is through head, so reaching index i means following i links.

How to use it

  • With a Value: Add First, Add Last, Remove First, Remove Last.
  • With an Index: Access, Add at Index, Remove at Index. Clear empties the list.
  • Linear Search, Traverse, Reverse (with prev / curr / next pointers) and Bubble Sort are animated; Cancel stops them.

Costs

OperationTime
Add first / remove firstO(1)
Add last (walks to the last node)O(n); O(1) with a tail pointer
Remove last (needs the node before it)O(n)
Access, search, add/remove at an indexO(n)
ReverseO(n), O(1) extra space

Visits counts the nodes walked; Changes counts pointer updates.