liveBook · Manning

Head pointer

As explained in Grokking Data Structures

A head reference is a reference identifying the first node of a linked list.

A head pointer is a reference to the first node in a linked list. In a singly linked list, the head node has no predecessor, so the list stores its reference separately. Setting the head to None represents an empty list. section 6.4 section 6.6

The head pointer gives several list operations their practical behavior:

  • Accessing the head is constant time because the list already stores its reference. section 6.24
  • Inserting before the head updates the stored reference to the new node. section 6.24
  • Deleting the head updates the pointer to the removed node’s successor; this is also constant time. section 6.10 section 6.9
  • Deleting another node requires traversing from the head while retaining its predecessor, because singly linked nodes only point forward. section 6.9

An empty Python list

A singly linked list can begin with no first node: class SinglyLinkedList: def __init__(self): self._head = None. Adding a first node later means changing _head to reference that node. section 6.6

class SinglyLinkedList:
    def __init__(self):
        self._head = None

Inspect the minimal Python initialization that stores the head reference and represents an empty list with None. section 6.6

How Grokking Data Structures covers it

How deep it goes
Defines head ownership, empty-list representation, predecessor limits, and constant-time head operations, while broader deletion remains linear.
Examples
Uses a Python list wrapper initialized with _head = None and demonstrates deleting the first node by updating that reference.
What it assumes
Assumes references, nodes, and successor links, while introducing the head as the separately stored first-node reference.
What you can do after
Operate singly linked lists by recognizing empty lists and updating the head when inserting or deleting at the front.
How it connects
Connects singly linked lists with nodes, tails, traversal, insertion, deletion, arrays, and stacks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Data Structures. The section links point to the parts of the book it draws on.