Chapter 8: "List with a Linked Structure" Data Structures with Java, Rick Mercer Answers to Self-Check Questions: 8-1 first.data.equals("Bob") 8-2 first.next.data ("Chris"); 8-3 first.next.next.next.data.equals("Zorro"); 8-4 first.next.next.next refers to a Node with a reference to "Zorro" and null in its next field. 8-5 drawing of memory -a- first IS nUll -b- first o-->["Chris"|/] -c- first o-->[2|o]-->[1|/] 8-6 c would fail ("JO" should be "Jo") 8-7 which would throw an exception -a- IndexOutOfBoundsException -c- the largest valid index is currently 4 -d- Okay since the largest index can be the size, which is 4 in this case 8-8 if switched, ref would move one Node too far and cause a NullPointerException 8-9 assertions - listed in correct order OurLinkedList list = new OurLinkedList(); list.addLast("A"); list.insertElementAt(0, "B"); list.addFirst("C"); assertEquals(__"[C, B, A]"__, list.toString()); // a. ========= list.remove("B"); assertEquals(___"[C, A]"__, list.toString()); // b. ====== list.remove("A"); assertEquals(____"[C]"_____, list.toString()); // c. === list.remove("Not Here"); assertEquals(____"[C]"_____, list.toString()); // d. === list.remove("C"); assertEquals(_____"[]"_____, list.toString()); // e. == 8-10 Whether or not a node actually exists at current.next. It could be null. 8-11 An array so the more efficient binary search could be used rather than the sequential search necessary with a linked structure.