CS With NehalCS With Nehal

Linked List Simulator

Insert, delete and search in a linked list stored in arrays, with the start and free pointers and every pointer change shown step by step.

Operations

Operations run step by step. Use the controls to pause or step through.

A linked list stored in arrays: Data[] holds the items, Next[] holds the index of the next node.

Linked list

Orange = current node, blue = previous node, green = new or freed node.

StartPtr = 0→
151
→
272
→
42∅
→
NULL
FreePtr = 3→ [3]→ [4]→ [5]→ [6]→ [7]

Drag to move · scroll to zoom

Arrays in memory

IndexDataNext
0151← StartPtr
1272
242NULL
34← FreePtr
45free
56free
67free
7NULLfree

Pseudocode

The current line is highlighted.

About This Simulation

This linked list simulator shows how a singly linked list is stored in arrays, as in the Cambridge AS Level syllabus. Each node is a row in the Data and Next arrays, a start pointer marks the first node and a free list holds the unused nodes. Every insertion, deletion and search runs step by step with the pseudocode alongside.

Features

  • Ordered insertion and insertion at the start
  • Deletion by value, returning the node to the free list
  • Search with the current node highlighted
  • Node diagram and the Data/Next arrays kept in sync
  • Start pointer and free pointer shown at every step
  • Pseudocode with the active line highlighted

Topics covered

  • Singly Linked List
  • Nodes and Pointers
  • Start Pointer
  • Free List
  • Insertion and Deletion
  • Linked List vs Array

Explanation

A linked list is a dynamic data structure made of nodes. Each node stores a data item and a pointer to the next node. The order of the list comes from the pointers, not from where the nodes are stored, so items can be added or removed without moving the others.

How it works

  1. StartPtr holds the index of the first node; a null pointer (−1) marks the end of the list.
  2. Unused nodes form a second linked list, the free list, starting at FreePtr.
  3. To insert, take the first free node, store the item in it and move FreePtr to the next free node.
  4. For an ordered list, follow the pointers until the next item is larger, then point the new node at it and point the previous node at the new node.
  5. To delete, find the node and the one before it, point the previous node past it, then add the deleted node to the front of the free list.

Why it matters

Linked lists are on the Cambridge 9618 AS Level syllabus and in university data structures courses (CSE220). They are the basis of stacks, queues, hash table chaining and adjacency lists, and they teach pointer manipulation.

Frequently Asked Questions

What is the free list in a linked list?

A linked list of the unused nodes. New items take a node from the free list, and deleted nodes are returned to it.

What are the advantages of a linked list over an array?

Items can be inserted or deleted by changing pointers, without shifting other items, and a dynamic linked list can grow and shrink as needed.

What are the disadvantages of a linked list?

Each node needs extra memory for its pointer, and items cannot be accessed directly by index: you must follow pointers from the start, which is O(n).

How is the end of a linked list marked?

The last node's pointer is a null pointer, often −1 or 0 when the list is stored in an array.

Related Simulations