390 likes | 405 Views
Learn about LinkedList implementation in Java, covering insertion, deletion, and node manipulation techniques with detailed explanations and examples. Understand how to create, delete, and manipulate nodes effectively in a linked list data structure.
E N D
Figure 4.1 a) A linked list of integers; b) insertion; c) deletion
Figure 4.2 A reference to an Integer object
Figure 4.3a-d a) Declaring reference variables; b) allocating an object; c) allocating another object, with the dereferenced object marked for garbage collection
Figure 4.3e-g e) allocating an object; f) assigning null to a reference variable; g) assigning a reference with a null value
Figure 4.4 The value of a parameter does not affect the argument’s value
Figure 4.5 A node
Figure 4.6 The result of linking two instances of IntegerNode
Figure 4.7 Using the Node constructor to initialize a data field and a link value
Figure 4.8 A head reference to a linked list
Figure 4.9 A lost node
Figure 4.10 The effect of the assignment curr = curr.getNext( )
Figure 4.11 Deleting a node from a linked list
Figure 4.12 Deleting the first node
Figure 4.13 Inserting a new node into a linked list
Figure 4.14 Inserting at the beginning of a linked list
Figure 4.15 Inserting at the end of a linked list
Figure 4.16 When prev references the last node and curr is null, insertion will be at the end of the linked list
Figure 4.17 When prev is null and curr references the first node, insertion or deletion will be at the beginning of the linked list
Figure 4.18 A reference-based implementation of the ADT list
Figure 4.19 A head reference as an argument
Figure 4.20 a) A sorted linked list; b) the assignment made for insertion at the beginning of the list
Figure 4.21a and 4.21b a) The initial call insert Recursive(head, newItem); b) the first recursive call
Figure 4.21c c) the second recursive call inserts at the beginning of the list that headNode references
Figure 4.22 A linked list with head and tail references
Figure 4.23 A circular linked list
Figure 4.24 A circular linked list with an external reference to the last node
Figure 4.25 A dummy head node
Figure 4.26 a) A dummy head node with global information; b) a head record with global information
Figure 4.27 A doubly linked list
Figure 4.28 a) A circular doubly linked list with a dummy head node; b) an empty list with a dummy head node
Figure 4.29 Reference changes for deletion
Figure 4.30 Reference changes for insertion
Figure 4.31a and 4.31b a) Inventory list node; b) wait list node
Figure 4.31c c) orthogonal structure for the inventory
Figure 4.32 Linked list for Self-Test Exercise 2, 3, and 7
Figure 4.33 Two circular linked lists
Figure 4.34 A sparse polynomial
Figure 4.35 a) An array-based implementation of the linked list in Figure 4-32; b) after inserting D in sorted order; c) after deleting B