EZ

Eduzan

Learning Hub

Eduzan
Eduzan / DSA in Python

Linked Lists in Python

A linked list is a linear data structure where elements are stored in nodes, and each node points (links) to the next node using references. Unlike Python lists (dynamic arrays), linked lists do not store elements in contiguous memory. This makes certain operations (especially insertions/deletions in the middle) efficient because you only change links rather than shifting elements.

Key idea: In a linked list, the “order” is maintained by pointers, not by indexes.

When to use linked lists:

  • You do lots of insertions/deletions in the middle of the sequence.
  • You don’t need fast random indexing (because linked lists are slow for index access).

When NOT to use:

  • You need frequent random access like arr[i] (Python lists are better).
  • You want cache-friendly performance (arrays are usually faster in practice).

End of lesson.