CMPSCI 250: Introduction to Computation

Solutions to Final Exam

David Mix Barrington

7 May 2014

Directions:

  Q1: 10 points
  Q2: 30 points
  Q3: 30 points
  Q3: 20+10 points
  Q4: 30 points
Total: 120+10 points

Exam text is in black, solutions in blue.

Definitions:

Question 2 refers to the following five statements, where the variables are of type "dog", the set of dogs includes the dog Duncan (d) and possibly others, and we use the following predicates:

The statements are:

N is the set of naturals (non-negative integers), {0, 1, 2, 3,...}

Question 3 uses a function f from N to N. The function arises in a popular video game where tiles are labeled by integers that are powers of two. The smallest tiles are labeled 2, and they are created without any points being scored. (We will assume for this exam that only tiles with label 2 are created, though actually the game also creates some with label 4.) When two tiles each with label 2k are merged, a single tile with label 2k+1 is created and the player gets 2k+1 points.

For any positive natural k, f(k) is defined to be the number of points scored in the process of creating a tile with label 2k. If k > 1, this includes the 2k points for the last merge creating the tile, plus all the points scored in the process of creating the tiles that were merged.

Question 4 uses the following two formal languages over the alphabet {a, b}. The language X is the set of all strings that do not have both two a's in a row and two b's in a row. The language Y is defined inductively as follows. Note that the text in green was omitted when the test was given.

  1. The string λ is in Y.

  2. If the string w in Y can be written as uaa for some string u, then wa = uaaa is in Y.

  3. If the string w in Y can be written as ubb for some string u, then wb = ubbb is in Y.

  4. If the string w in Y cannot be written as either uaa or ubb, then both wa and wb are in Y.

  5. The only strings in Y are those that are forced to be by rules (1)-(4).

Question 5 uses the following λ-NFA N. The alphabet is {a, b}, the state set is {1, 2, 3, 4, 5}, the start state is 1, the final state set is {5}, and the transition relation Δ is

{(1, a, 2), (1, a, 3), (2, b, 4), (3, a, 5), (4, λ, 2), (4, λ, 3), (5, a, 4)}.

Here is a diagram of N, with "L" meaning λ:


       a         a
>(1) ----> (3) ----> ((5))
  |         ^         /
  |         |        /
  |         |       /
  |         |      /
  |a        |L    / a
  |         |    /
  |         |   /
  |         |  /
  |         | /
  V    b    |V
 (2) ----> (4)
     <----
       L