Follow the References!

  • Trace the basic operations of a (singly) linked-list implementation.

Consider the following linked list:

Exercise In each case, draw a schematic representation of the linked list after the statement is executed. For each statement, start with the linked list displayed above.

head = head.next;
Solution

We effectively removed the first element!

head.next = head.next.next;
Solution

We effectively removed the second element!

head.next.next.next.next = head;
Solution

We effectively created a circular linked list!