


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: Quiz; Class: Full Course Title: Program Design and Development; Subject: COMPUTER SCIENCE; University: University of Arizona; Term: Summer 2008;
Typology: Quizzes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



// This heading ensures that the key implements Comparable so you can use the // compareTo method on the key. If type K does not, the compiler complains. public class OrderedMap<K extends Comparable
emptyTree M M M / \ /
G R G R / \ /
B K P W
public boolean isFull() { return isFull(root); } private boolean isFull(MapNode t) { if (t == null ) return true ; else if ((t.left == null && t.right != null ) || (t.left != null && t.right == null )) return false ; else return isFull(t.left) && isFull(t.right); }
public int numberOfKeysGreaterThan(K key) { return keysGreaterThan(key, root); } private int keysGreaterThan(K key, MapNode t) { if (t == null ) return 0; else { int result = 0; if (t.key.compareTo(key) > 0) result = 1; return result + keysGreaterThan(key, t.left)