DSA Lab

Linked list

A linked list stores each value in its own node, and every node holds a pointer to the next one. The nodes can be anywhere in memory; the pointers give the order.

Linked list: how it works

In this tool: insert, delete, search, reverse. Put in your own values and watch it change. Each operation runs one step at a time and says in plain words what happened, with its calculation worked out. The code is shown in Python, C, C++ or Java with the line that just ran marked, and an Understand it panel gives the idea, why it works, the cost of each operation, common mistakes and a short quiz.

Lessons that use it

  • Linked lists (Python)Chain objects together with references, walk the chain, insert in the middle, and reverse it.
  • Singly linked lists (Data Structures)Append with a tail pointer, search, and delete a value while keeping the chain joined.
  • Doubly and circular linked lists (Data Structures)Nodes with prev and next pointers, removing a node in O(1), and a circle of nodes for the Josephus problem.
  • Linked list patterns (Interview Prep)Reversing a list in place, fast and slow pointers for the middle and for cycles (Floyd's algorithm), merging two sorted lists, and the dummy-head trick.