final-2003sp - Final Examination Computer Science 312,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Final Examination Computer Science 312, Cornell University 15 May 2003 1. True/False [12 pts] (parts af; 4 points off for each wrong answer, 2 points off for each blank answer, minimum problem score 0.) a. With copying garbage collection, half of the heap storage is unused while the program executes. b. SML infers that the term (fn(x,y)=>x, fn(x,y)=>y) has a type equivalent to (a*b->a)*(c*d->d) . c. The shortest-path algorithm does not work correctly in general if any edges of the graph have zero weight. d. A string searching algorithm that looks for a pattern string in a larger text string (for example, the Boyer-Moore algorithm) must examine each character of the text string to avoid missing an occurrence of the pattern string. e. The treap data structure simultaneously satisfies both the heap ordering invariant and the binary search tree invariant. f. In the environment model an expression of the form (fn x => e ) evaluates to an unboxed value. 2. Zardoz [15 pts] (parts ab) For each of the following expressions, give an expression to replace the box , so that the entire containing expression evaluates to 42. (a) [7 pts] let val zardoz: (a->b->a) * (string * int) = fun g(z: (a->b->a) * (b*a)): a = let val (f, (m, n)) = z in f n m end in g(zardoz) + String.size (#1 (#2 zardoz)) end Your answer: 1 (b) [8 pts] let fun zardoz (m: int -> int) (k: int) = if k > 13 then else m k - zardoz m (k + 1) in zardoz (fn i => i + 3) 12 end Your answer: 3. Strings [8 pts] (parts ab) Consider the following finite automaton: a b a c b Recall that a finite automaton accepts any strings consisting of the symbols traversed...
View Full Document

Page1 / 6

final-2003sp - Final Examination Computer Science 312,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online