CMPSCI 250: Introduction to Computation

Solutions to Second Midterm Exam Fall 2018

David Mix Barrington and Marius Minea

Exam given 7 November 2018

Solutions posted 19 November 2018

Directions:

Exam text is in black, solutions in blue.

  Q1: 10+10 points
  Q2: 20 points
  Q3: 40 points
  Q4: 30 points
Total: 100+10 points

Here are definitions of some terms, sets, predicates, and statements used on this exam.

Remember that a natural is a non-negative integer, so that the set N or all naturals is {0, 1, 2, 3,...}.

The Fibonacci function is recursively defined by the rules F(0) = 1, F(1) = 1, and (for all n > 0) F(n+1) = F(n) + F(n-1).

Let E(n) be recursively defined by the rules E(0) = 0, E(n+1) = 3E(n) + 6 for even n, and E(n+1) = 2E(n) + 3 for odd n.

Let V(n) be recursively defined by the rules V(0) = 1, V(n+1) = 3V(n) + 1 for odd n, and V(n+1) = 2V(n) + 1 for even n.

The set S of strings over the alphabet {a, b, c} is defined as follows:

There are exactly ten strings in S with length ≤ 2: λ, a, b, c, ab, ac, ba, bc, ca, and cb.

For any natural n, we define an undirected graph Gn whose nodes are labeled by the strings in S of length ≤ n. If w is a string in S, x and y are letters, wx and wy are both in S, and |wx| = |wy| ≤ n, then there are edges (w, wx), (w, wy), and (wx, wy) in G.

Equivalently, we can define the graphs Gn inductively as follows.


Undirected graphs G_0, G_1, and G_2, G_3. "L" means "lambda".
Numbers 1 or 2 within edges are edge weights for Question 3 (c) and (d).
In G_2, the edge (a, c, 1) is drawn crossing (b, ba, 2) and (b, bc, 2).


G_0   L     G_1     L          G_2                L
                   /|\                           /|\
                  / | \                         / | \
                 2  2  2                       2  2  2
                /   |   \                     /   |   \
               /    |    \                   /    |    \
              a--1--b--1--c                 a--1--b--1--c
               \         /                 /|\   / \   /|\ 
                \---1---/                 / | --/-1-\-- | \
                                         2  2  2     2  2  2
                                        /   |  |     |  |   \
                                       /    |  |     |  |    \
                                      ab-1--ac ba-1-bc ca--1-cb

G2 is a graph with ten nodes and fifteen edges.

The alphabetical order on strings is defined as follows:

Last modified 21 November 2018