← Back to the linked lists page

Singly Linked List

Each node points forward only. Cheap insertion at the head, but you can never look back — which is exactly what the classic tricks exploit.

What to know

  • Fast/slow pointers meet inside a cycle (Floyd); resetting one to head finds the cycle start.
  • Reversal rewires next pointers one node at a time with three cursors (prev/curr/next).
  • A dummy head node removes every "is it the first node?" special case.

In the wild: Hash table chaining buckets, immutable functional lists, memory allocator free lists.

Algorithms to reach for

Floyd’s cycle detection

O(n)

Detect and locate loops without extra memory

Iterative reversal

O(n)

Reverse whole list or k-groups in place

Fast/slow middle finding

O(n)

Find midpoint in one pass (merge sort on lists)

Merge two sorted lists

O(n + m)

Zipper-merge by relinking, no allocation