CHAPTER 12 - Java Software Solutions, 4e Chapter 12...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Software Solutions, 4e Lewis/Loftus Chapter 12 Chapter 12 Exercise Solutions 12.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. 12.2. // assumes each node has a reference field called “next” // assumes “next” refers to a subsequent node if there is one if current.next is not null then current.next = current.next.next; endIf 12.3. Modify your answer to the previous exercise assuming that the list was set up as a doubly linked list, with both next and prev references. 12.4. if current.next is not null then if current.next.next is not null then current.next.next.prev = current; endIf current.next = current.next.next; endIf 12.5. 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. 12.6. // assumes each node has a reference field called “next” // assumes “next” refers to a subsequent node if there is one newNode.next = current.next; current.next = newNode; 12.7. Modify your answer to the previous problem assuming that the list was set up as a doubly linked list, with both next and prev references. 12.8.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Software Solutions, 4e Lewis/Loftus Chapter 12 newNode.prev = current; if current.next is null then newNode.next = null; else newNode.next = current.next; current.next.prev = newNode; endIf current.next = newNode; 12.9. 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. 12.10.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Page1 / 5

CHAPTER 12 - Java Software Solutions, 4e Chapter 12...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online