| CIT594 Final Exam Answer Key Spring 2004 |
Name_________________________________________ |
Please read each question carefully, and answer the question that is asked, not some related question. Keep answers brief--you have enough room for correct answers. Write legibly--if I can't read your answer, it's wrong.
Set and
List. Map
and TreeMap. public void testXxx()
method will be called automatically. equals method.hashCode method. public class BooleanArray {
public boolean[] bits = new boolean[32];
}BooleanArrayIterator class (implementing
Iterator) for this class,remove method for this class doesn't
seem to make much sense, but Java requires that you have one, what should
your remove method do?BinaryTree
class:
public class BinaryTree {
BinaryTree leftChild, rightChild;
Object value;
... }
Write an instance method to determine whether two binary trees are equal (same
shape, same values).<integer>. An integer
should consist of an optional plus or minus sign, followed by one or more
digits. Assume that <digit> has already been defined.doubles using only a map (no linked lists), that provides
both fetch and store operations. To do this,
import java.util.HashMap;
public class SparseArray {
HashMap map = new HashMap(500);
public void store(int row, int column, double value) {
map.put(row + "," + column, new Double(value));
}
public double fetch(int row, int column) {
Object obj = map.get(row + "," + column);
if (obj == null) return 0.0;
else return ((Double) obj).doubleValue();
}
}
|
G, A,
T, C in the proportions 1:2:4:8. That
is, A is twice as likely to occur as G; T
is twice as likely as A; and C is twice as likely
as T. If you use a Huffman encoding, what is the average number
of bits required per letter?
f(N) = g(N)
+ h(N).f(N) values used for?N?g(N)?h(N)?f(N)?Person p = new Person(); is executed,