# CMPSCI 250: Introduction to Computation

### David Mix Barrington

### Fall, 2004

# CMPSCI 250 Practice Midterm #2

#### Posted 23 October 2004

#### Actual midterm will be 28 October 2004

There are six questions for 100 total points.

Question 5 (a) corrected 26 Oct 2004.

**Question 1 (10):**
Prove ∃a:∀b:(b≥a)→[∃c:(b<3c)∧(3c<2b)].
This can be done without mathematical induction.

**Question 2 (10):**
Prove *by induction* that for all naturals n, (n+1)/2≤n. Here the
"/" is the Java integer division operator.

**Question 3 (20):**
This problem concerns the three naturals 64, 77, and 91.

- (a,10) Run the Euclidean Algorithm on 77 and 64, on 91 and 64, and on 91 and 77.
Which pairs are relatively prime?
- (b,5) Are these three numbers pairwise relatively prime? Explain your answer.
- (c,5) Pick one of the pairs that are relatively prime and find integers x and y
such that x times one number plus y times the other number equals 1.

**Question 4 (20):**
Prove ∀a:∀b:(b>0)→[∃q∃r:(a=qb+r)∧(r<b)].
(Hint: Let b be arbitrary, assume b>0, and use strong induction on a, with P(a)
being the predicate in square brackets.)

**Question 5 (20):**
Define the function f from strings in {a,b}^{*} to strings in {0,1}^{*}
by the following rules:

- f(λ)=λ
- For any string u in {a,b}
^{*}, f(ua) = f(u)0 and f(ub) = f(u)01

Prove the following, where u is in {a,b}^{*} and w is in {0,1}^{*}:

- (a,10) ∀u:|u|≤|f(u)|≤
2|u| (Statement corrected
26 Oct 2004.)
- (b,10) ∀w: w∈(0+01)
^{*}→∃u:f(u)=w (Hint: Remember
that (0+01)^{*} has an inductive definition on which you can do inductive proofs.)

**Question 6:(20)**
Define a **directed ternary tree (DTT)** by the following rules:

- A single node is a DTT, and the node is its root.
- If S, T, and U are DTT's, and x is a new node, then the graph made from x, S, T,
and U by adding arcs from x to the roots of S, T, and U is a DTT, and x is its root.
- Nothing else is a DTT.

Recall that a **leaf** is a node with no arcs out of it. Prove that in any DTT,
the number of leaves is twice the number of non-leaves, plus one.

Last modified 26 October 2004