This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Preliminary Examination II Computer Science 312, Cornell University 15 April 2008 1 1. Cookie [2 pts] What kind of cookie did you take? 2 2. True/False [14 pts] (parts a–g) a. The adjacency matrix representation of a graph with N nodes (vertices) and E edges takes O ( N ) space. b. Mutators have observable side effects. c. Closed hashing exhibits poor performance when α is close to 1. d. Suppose we resize hash tables by growing the array by a constant amount, rather than by doubling. Then the amortized asymptotic performance of inserting one element into the hash table would be O ( n ) in the number of elements, rather than O (1) . e. According to the redblack tree invariant, the smallest number of nodes that will guarantee the tree contains a red node is 4. f. Redblack trees have a representation invariant that is strictly stronger than that of binary search trees. g. Amortized worstcase performance cannot be worse than (nonamortized) worstcase performance. 3 3. The Zardoz Imperative [10 pts] Give a value that causes the expression to evaluate to 42 if the box is replaced by that value. Your answer may not contain any integer constants. let datatype mlist = Nil  Cons of int * (mlist ref) val cells: mlist = Cons(20, ref(Cons(21, ref(Cons(23, ref Nil))))) (* the value for refrobulate may not contain any integer constants. *) val refrobulate: mlist > unit = in refrobulate cells; case cells of Cons (n1, c1) => (case !c1 of Cons (n2, c2) => (case !c2 of Cons (n3, c3) => n2 + n3  Nil => 0)  Nil => 0)  Nil => 0 end 4 4. Asymptotic complexity [24 pts] (parts a–c) A matrix is a twodimensional array of numbers. Two square matrices with n elements on a side each contain n 2 elements. The conventional algorithm for multiplying two square matrices of sizeelements....
View
Full Document
 Spring '09
 Computer Science, Analysis of algorithms, hash function, val refrobulate

Click to edit the document details