
156 Introduction to Computational Models with Python
the head reference head with None. T he following example checks the linked
list referenced by listObj if empty.
if listObj.empty() == True:
. . .
A node can be ins erted in the linked list at the front, at the back, or in any
other place specified. Method insertFirst creates and inserts a new node at
the front of a linked list, given the data for the node. T he new node bec omes
the head or front node of the linked list and the method increments the value
of attribute numnodes. Figure 10.3 shows the insertion of a new node to the
front of the list.
Figure 10.3 A new nod e inserted in the front of