Exercise Solutions, Ch. 13
Chapter 13 Exercise Solutions
EX 13.1. Suppose current is a reference to a Node object and that it currently
refers to a specific node in a linked list. Show, in pseudocode, the steps that would
delete the node following current from the list. Carefully consider the cases in
which current is referring to the first and last nodes in the list.
if current.next is not null then
EX 13.2. Modify your answer to Exercise 13.1 assuming that the list was set up as a
doubly linked list, with both next and prev references.
if current.next is not null then
EX 13.3. Suppose current and newNode are references to Node objects. Assume
current currently refers to a specific node in a linked list and newNode refers to
an unattached Node object. Show, in pseudocode, the steps that would insert
newNode behind current in the list. Carefully consider the cases in which
current is referring to the first and last nodes in the list.
newNode.next = current.next;
EX 13.4. Modify your answer to Exercise 13.3 assuming that the list was set up as a
doubly linked list, with both next and prev references.
newNode.prev = current;
EX 13.5. Would the front and rear references in the header node of a linked list ever
refer to the same node? Would they ever both be null? Would one ever be null if
the other was not? Explain your answers using examples.
The front and rear references in the header node of a linked list would refer to the same