Sample Problems -- CMSC 331 -- Spring 17
Stuff to Study and/or Think About
1. What are the types of the following:
fun zed x = x + 1;
fun f g (a,b) = (f g a, g f b);
fun f [] = 0 |
f (a::b) = a + (f b);
fun that [] = [] |
that ((a,b)::l) = ((a+1)=b)::that(l);
2. Write a ML function to sort a list of strings.
3. Use a truth table to show that ~(A \/ B) = (~A /\ ~B)
4. Write a grammar which generates all of the sentences (abc)^n
(n>0 copies of abc)
5) Write the ML code to implement the stack Data Structure:
top(empty) = ERROR pop(empty) = empty
top(push(a,S)) = a pop(push(a,S)) = S
6) Write a BNF grammar for the propositional calcuulus.
Then, write an EBNF version.
7) Write a ruby function to find the smallest int in an int list.
8) Assuming x & y are both ints, determine the weakest precondition for:
if (x > y)
then y = 2*x + 1
else y = 2*x - 1
end
{ y > 3 }
9) compare and contract: check & unchecked exceptions
10) Given the definitions:
2 = \f . \x. f (f x)
plus = \m. \n. \f. \x. m f (n f x)
compute the value of (plus 2 2)
11) Is it possible to pass objects by value? Discuss.
12) Compare and contrast cooperative/competitive synchronization.
13) Give two reasons why languages need to provide support for concurrency.
14) Describe two unique features of Ruby Exception Handling.
15) Why do many languages allow multiple catches in a try-catch construct?
16) Semaphores are made up of what two primary structures?
17) Which types of parameters (in/out/in-out) can be used in a recursive function.
18) What features of HDFS are used to make Map-Reduce more efficient?