


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Full Course Title: Program Design and Development; Subject: COMPUTER SCIENCE; University: University of Arizona; Term: Summer 2006;
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



last = new Node("B"); last.next = new Node("A", last);
// Code could have been written like his also Node first = new Node("A"); first.next = new Node("B"); "A" (^) "B" first
public void addFirst (E element) { first = new LinkNode(element, first); }
public void addLast(int index, E element) { if (front == null) first = new Node(element); else { // General case Node ref = first; while (ref.next != null) { ref = ref.next; } ref.next = new Node(element); } }
public void size () { int result = 0; LinkNode ref = first; while(ref != null) { ref = ref.next; result++; } return result; }
private int sum(Node n) { if(n!=null) return n.data + sum(n.next); else return 0; }
private K maxKey(MapNode t) { if (t.right == null) return t.key; else { return maxKey(t.right); } }
public String toString() { return toString(root, ""); } private String toString(MapNode t, String result) { if (t == null) return ""; else return toString(t.left, result)