You are on page 1of 5

COT 3100: Spr 2012 Final exam, 120 min. PROBLEM 1.

SOLUTION
There are 6 problems on this exam on 6 pages. Write your name on each page. Write your
section number on the first page. Keep your answers to each problem on its own page. You may
write on the back, if needed.
(14 points) Let p be the statement Prof. Davis is walking in the rain. Let q be the statement
Prof. Davis gets wet. Suppose p q is always true.
(a) State the contrapositive as a logical proposition.
Solution: q p
(b) State the contrapositive in English.
Solution: If Prof Davis does not get wet, then he is not walking in the rain.
(c) State the inverse p q in English.
Solution: If Prof davis is not walking in the rain, he does not get wet.
(d) If p q is always true, does this imply the inverse is always true? (answer yes or no):
Solution: NO
(e) Demonstrate your answer to (d) with a logical proof or with a truth table (the latter is
probably easier).
Solution: Here
p q pq
T T
T
F
T F
F T
T
F F
T

is a truth table
p q p q
F
F
T
F T
T
T F
F
T T
T

Note that if p q is always true, it means the 2nd row of the truth table cannot hold.
However, the 3rd row can, and in this case p q is false.
(f) If your answer to (d) is yes, explain. If your answer to (d) is no, determine the value(s)
of p and q for which (p q) is true yet the inverse is false.
Solution: p can be false and q can be true (3rd row of table above)
(g) Give a practical example for your answer in (f).
Solution: Davis can get wet through other means ... like a bottle of water poured on his
head.

COT 3100: Spring 2012 FINAL, PROBLEM 2.


(15 points) Consider Hilberts Hotel, with a countably infinite number of rooms, each with a
guest (the Hotel is full). The management decides to close all the even numbered rooms. Show
that all guests can remain in the hotel. Be precise; provide a rule or formula that tells the guest in
room n what new room he or she must move to.

COT 3100: Spring 2012 FINAL, PROBLEM 3.


(15 points) Let P (n) be the conjecture that all sets of n horses have the same color. What is
wrong with this proof that all horses have the same color?
To show that P (n 1 implies P (n), consider a set of n horses. Place them in a sequence. The
first n 1 horses have the same color, by induction (P (n 1)), and likewise the last n 1 horses
have the same color, also by induction (P (n 1)), Since these two sets share a horse in common
(the 2nd horse for example), all n horses have the same color. This is the statment P (n), and thus
P (n 1) P (n).
Solution: The proof has two flaws. It has no base case (P (1)). The induction step only works
for P (2) P (3), and P (3) P (4), and so on. It does not work for P (1) P (2), because in this
case the two subsets do not share a horse in common.

COT 3100: Spring 2012 FINAL, PROBLEM 4.


Consider the following recursive (pseudocode) algorithm for finding both the smallest and largest
value in an array. Let A (i ... j) denote the region of the array A starting at position i and
ending at position j. If you have any question about how the pseudcode is written or what it means,
please ask.
find_min_max (A, amin, amax)
// input array A of size n
// output scalar values amin and amax
if (n == 1)
amin = A (1)
amax = A (1)
else
find_min_max (A (
1 ... n/2 ), amin1, amax1)
find_min_max (A ( (n/2)+1 ... n), amin2, amax2)
if (amin1 < amin2)
amin = amin1
else
amin = amin2
endif
if (amax1 > amax2)
amax = amax1
else
amax = amax2
endif
end
(5 points) write a recurrence relation T (n) = ... that counts the number of comparisons need
by the algorithm.
Solution: T (n) = 2T (n/2) + 2
(10 points) find a solution to T (n) in terms of big-O notation, using the Master Theorem.
Solution: Compare logb a = log2 2 = 1 with d = 0. The former is larger, so T (n) is O(n).

COT 3100: Spring 2012 FINAL, PROBLEM 5.


(16 points) Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) R if and only if
(a) x + y = 0
Solution:
not reflexive (since 1 + 1 6= 0),
symmetric (since x + y = y + x),
not antisymmetric (since both 1 + (1) = 0 and (1) + 1 = 0),
not transitive (for example, (1, 1) and (1, 1) are in R but (1, 1) is not).
(b) x = y
Solution:
reflexive (since x = x),
symmetric (since x = y if and only if y = x),
not antisymmetric (since (1, 1) and (1, 1) are both in R),
transitive (if x = y and y = z then x = z always holds).
(c) x y is a rational number
Solution:
reflexive (since x x = 0 is rational)
symmetric (since if x y is rational, so is y x = (x y))
not antisymmetric (since (1, 1) and (1, 1) are both in R)
transitive (since if xy is rational and y z is rational then their sum xy +y z = xz
is rational).
(d) xy 0
Solution:
reflexive (since x2 0)
symmetric (since xy = yx)
not antisymmetric (since (2, 3) and (3, 2) are both in R)
not transitive (since (1, 0) is in R and (0, 2) is in R, but (1, 2) is not in R).

COT 3100: Spring 2012 FINAL, PROBLEM 6.


(a) (5 points) Define the term strongly connected component
Solution: A strongly connected component is a maximal vertex-induced subgraph that is
strongly connected. A graph is strongly connected if for every pair of nodes a and b, there is
a path from a to b.
(b) (15 points) Find the strongly connected components of each of the following graphs.
Solution:
graph (a) has three components: (a,b,c), (d), and (c)
graph (b) has four components: (a), (b), (c,d,e), and (f)
graph (c) has two components: (a,b,c,d,f,g,h,i), and (e)

You might also like