CIT 594 Midterm Spring 2005, Dave Matuszek 
Name _______________________________________

node.
Assume
you have methods getLeftChild()
and getRightChild()
.
I've started it for you:
int countNodes(BinaryTree node) { if (node == null) return 0; } 
n
= number of nodes n
to mean the depth of the tree
in question #1 (that is, how far it is from node to its deepest descendant),
and we assume that the tree is balanced, what is the time required (using
BigO notation) to execute the method in question #1?Vector
has methods int size()
and
int capacity()
. What is the difference?
size()
returns:capacity()
returns:LinkedList
implements Iterator
. Write a
loop to print all the elements of a LinkedList
named myList
.T
or F
):
Stack
has both empty()
and isEmpty()
methods. equals(Object)
you must also override
hashCode()
.hashCode()
you must also override
equals(Object)
.Observer
you must have a class that
extends Observable
.Observable
you must have a class that
implements Observer
.String
parameters can be passed to an applet.


try { leafB2.setLeftChild(rootAB); fail(); } catch (IllegalArgumentException e) { System.out.println("This call would form a loop."); } 
Collection
interface, other than the
ones mentioned in the previous question. (Use the form Map
interface. (Use the form x
and y
are the same type.
public class Pair { 
myPair
with components of type Integer
and Double
, and assign some reasonable value to it.
for (int i = 0; i < myArray.length; i++) { myArray[i] = 0; // loop invariant: } 
log_{2} 100
is between ________ (next lower
integer) and ________ (next higher integer).HashMap
without writing
your own hashCode()
method.Add
. Add
should have a factory method makeAdd()
,
no other methods, and no instance variables. Write the complete class
definition.
public class Add { 
0x
digits
or 0X
digits, where digits is one
or more hexadecimal digits (case insensitive). Write a BNF definition (simple
or extended, your choice) for a hex number; do not worry about limiting
the number of digits.boolean hexDigit()
method.
boolean hexNumber( ) { 