Linked List Question ==================== For some of the L0101 versions, change "value" to "data", "link" to "next", "head" to "first". Solution: Node current = head; while (current != null) { // New node with same value Node duplicate = new Node(); duplicate.value = current.value; // Insert after current (before is trickier!) // // I hope you drew a picture if you had any trouble. // duplicate.link = current.link; current.link = duplicate; // Skip newly inserted node. current = duplicate.link; } Marking guide: Not messing up head: 1 mark Starting, ending correctly: 1 mark Making duplicate with same value: 2 marks Inserting properly: 2 marks Moving forward properly: 2 marks Recursive Stack Question ======================== L0101 ----- The following is the solution for one version of the test. For other versions, change "n" to "i", "T" to "E". if (n == 0) { return s.pop(); } else { // Without the first element, the nth element is the n-1st. // So remove first element, get n-1st, put back first element. T first = s.pop(); T result = remove(s, n-1); s.push(top); return result; } Marking guide: n == 0: 2 marks else recurse: 2 marks recursing on rest of s, n-1: 2 marks restoring first: 2 marks L5101 ----- Solution: int result = 0; E first = s.pop(); if (!e.equals(first)) { result = 1 + depth(s, e); } s.push(first); return result; Marking guide: depth 0: 2 marks else recurse: 2 marks recursing on rest of s: 2 marks restoring first: 2 marks Memory Model Question: Marking Guide ==================================== Values of the i's: 5 marks covers to some extent the location of the i's Static space: 1 mark inheritance of D from C location of main, s Object space: 1 mark f and m inside all three overriding m in D's D's contain C parts Method stack: 1 mark m-f-main m/f inside x3 main inside m local variables c,d1,d2 refer to objects