final-fall09

final-fall09 - CMSC330 Fall 2009 Final Exam Name Do not...

Info iconThis preview shows pages 1–4. 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

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: CMSC330 Fall 2009 Final Exam Name Do not start this exam until you are told to do so! Instructions You have 120 minutes for to take this midterm. This exam has a total of 120 points. An average of 1 minute per point. This is a closed book exam. No notes or other aids are allowed. If you have a question, please raise your hand and wait for the instructor. Answer essay questions concisely using 1-2 sentences. Longer answers are not necessary and a penalty may be applied. In order to be eligible for partial credit, show all of your work and clearly indicate your answers. Write neatly. Credit cannot be given for illegible answers. Problem Score Max Score 1 Programming languages 9 2 Ruby 6 3 RE, CFL, automata 12 4 OCaml types & type inference 6 5 Lambda calculus 6 6 Scoping 6 7 Parameter passing 8 8 Lazy evaluation 6 9 Garbage collection 5 10 Multithreading 14 11 Ruby Multithreading 20 12 OCaml programming / GC 22 Total 120 1. (9 pts) Programming languages a. (3 pts) Briefly describe the difference between syntax and semantics of programming languages. b. (3 pts) Explain briefly what type inference is. c. (3 pts) List one of two possible scoping rules we discussed in class, and briefly describe a disadvantage for this approach. 2. (6 pts) Ruby What is the output (if any) of the following Ruby programs? Write FAIL if code does not execute. a. CMSC 330 =~ /([a-zA-Z]+)/ # Output = puts $1 b. a = { 1 => 2 } # Output = a.keys.each{ |x| puts a[x] } 3. (12 pts) Regular expressions, context-free grammars, and finite automata a. (6 pts) Convert the following NFA to a DFA using the subset construction algorithm. Be sure to label each state in the DFA with the corresponding state(s) in the NFA. 3 a 2 1 b 4 a & & b 3 a 2 1 b 4 a & & b b. (3 pts) Write a regular expression for the NFA above c. (3 pts) Write a context-free grammar for all binary numbers (strings consisting of 0s and 1s) of the form 0 n 1 m , where n = m+2 and m & 0. E,g,: 00, 0001, 00000111 4. (6 pts) OCaml types and type inference a. (3 pts) Give the type of f in the following OCaml expression let f x y = x + y in f 3 4 Type = b. (3 pts) Write an OCaml expression with the following type a -> 'a Code = 5. (6 pts) Lambda calculus (3 pts each) Evaluate the following -expressions as much as possible a. ( x.x) ( y.y) ( z.z) b. ( x. y.x) y 6. (6 pts) Scoping Consider the following OCaml code....
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 330 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 7

final-fall09 - CMSC330 Fall 2009 Final Exam Name Do not...

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

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