Practice Discrete Math

Algorithms / Linked List Dummy Nodes

Least You Need to Know: Dummy Nodes, Head Cases, and Stable Stitching

A dummy node is a fake node placed before the real head so that insertion and deletion at the front look like ordinary middle-of-list operations. Interviews love dummy nodes because they remove special-case branching and make stitched-together outputs easier to reason about.

The least you need to know

Key notation

dummy sentinel node before the real result
tail last node already attached to the built list
dummy.next real head of the constructed answer

Tiny worked example

  • To merge two sorted lists, start with a dummy node and a `tail` pointer at the dummy.
  • Each time you choose the smaller front node, attach it to `tail.next` and advance `tail`.
  • After one list empties, attach the whole remaining suffix of the other list.
  • Finally return `dummy.next`.

Common mistakes

How to recognize this kind of problem

Start practice