CMPSCI 250: Introduction to Computation

Second Midterm Exam Spring 2020

David Mix Barrington and Hia Ghosh

2 April 2020

Directions:

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

  • Question 1 (15): Define the function G from naturals to naturals recursively, by the rules G(0) = 0, G(1) = 1, and, for all n with n ≥ 1, G(n+1) = 5G(n) - 6G(n-1). Prove, by strong induction, that for all naturals n, G(n) = 3n - 2n.

  • Question 2 (20+10): These questions deal with a language L over the alphabet {a, b, c, d}, and a related set T of rooted trees with leaves labeled by letters from that alphabet. Both are defined recursively. The rules for L are:

    1. b is in L.
    2. If w is a string in L, then awc is in L.
    3. If u and v are both strings in L, then udv is in L.
    4. The only strings in L are those made using the first three rules.

    The rules for T are:

    1. A single node labeled by b is in T.
    2. If t is a tree in T, then the tree that has a root with three children: a leaf labeled a, t, and a leaf labeled c, is in T.
    3. If t and u are trees in T, then the three that has a root with three children: t, a leaf labeled d, and u, is in T.
    4. The only trees in T are those made using the first three rules.

  • Question 3 (35): These questions involve the following weighted undirected graph. The numbers in the middle of the edges give edge weights. The numbers in parentheses at each node are weights for the A* search in part (e).

    
                      q(7) 
                      /   \
                     1     1
                   /         \
                 r(6)        s(8)
                  |           |
                  1           3
                  |           |
                 t(5)        u(6)
                    \        /  \
                     2      3    2
                      \   /        \
                       v(3)        w(5)
                        |            |
                        2            3
                        |            |
                       x(1)         y(2)
                           \       /
                            2     2
                              \  /
                              z(0)
    
        

  • Question 4 (30): The following are fifteen true/false questions, with no explanation needed or wanted, no partial credit for wrong answers, and no penalty for guessing.

    Last modified 18 May 2020