COSC 2320 Chapter 17-18: Chapter 17-18
Document Summary
From presentation slides (list single: alist add(newentry) method. Assign new value at the end of list. Increment length of list: alist add(newpoistion, newentry) method. Assign new value at position of list. Shift existing entries to avoid gap in the array. Invalid call should return null value: llist. Class node firstnode references to the first node remember the address of the first node. Adding to the end of the empty linked based list firstnode = newnode; Adding to the end of the non-empty linked based list lastnode. next = newnode; Adding at the beginning of the linked based list. Adding at a given position within the linked based list. Removing from beginning of the list firstnode = firstnode. next; this removes first node. Nodebefore. next = nodeafter; this removes the middle node. If list has only 1 node firstnode = lastnode = null; If list has more than 1 node lastnode = nodebefore; Insertafter inserts the new node after a provided existing list node.