Solutions

Discrete Structures, Test 2
Monday, April 6, 2009
SOLUTIONS
1. (12 pts) Short answer. Put your answer in the box. No partial credit.
(a) If x, y are Boolean variables, simplify the Boolean expression (x ∨ y 0 ) ∧ (x ∨ y).
Your answer must be as simple as possible.
Solution: (x ∨ y 0 ) ∧ (x ∨ y) = x ∨ (y 0 ∧ y) = x ∨ 0 = x.
(b) Draw the Hasse diagram of the lattice (D8 , |), where | is the divisibility relation.
Solution:
(c) Compute d−3.52e.
Solution: −3.
(d) In the lattice (D30 , |), what is the complement of 15?
Solution: The complement of 15 is 30/15 = 2.
(e) List all the maximal elements of the poset whose Hasse diagram is below.
Solution: g.
(f) For the poset whose Hasse diagram is above, what is the greatest lower bound of
the set B = {c, d, f }?
Solution: c.
2. (8 pts) Consider the following functions
f1 (n) = n3 , f2 (n) = n lg n, f3 (n) = lg(n10 ), f4 (n)
= 3n , f5 (n) = n!,
√
f6 (n) = 600n2 − 3n + 12, f7 (n) = nn , f8 (n) = 3 n.
Put them in order from lowest Θ class to highest (in other words, in order from slowest
order of growth to fastest).
√
Solution: Θ(lg(n10 )) < Θ( 3 n) < Θ(n lg n) < Θ(600n2 − 3n + 12) < Θ(n3 ) < Θ(3n ) <
Θ(n!) < Θ(nn ).
1
This is because lg(n10 ) = 10 lg n = Θ(lg n) is less than the Θ class of any positive power
√
1
1
of n (such as 3 n = n 3 ). Then Θ(n lg n) > Θ(n) > Θ(n 3 ) since Θ(n) > Θ(1). Next,
Θ(600n2 − 3n + 12) = Θ(n2 ) > Θ(n lg n) since Θ(n) > Θ(lg n) ⇒ Θ(n · n) > Θ(n · lg n).
Then n3 is next. After that, the exponential 3n grows faster than any power of n. We
saw in class that Θ(nn ) > Θ(n!) > Θ(bn ) for any base b.
3. (6 pts) Give the Hasse diagrams of all the nonisomorphic lattices that have five elements
(there are 5 of them).
Solution:
Why are these the only nonisomorphic lattices with five elements? The first one is a
linear order. If a lattice is not a linear order, then its Hasse diagram must contain a
diamond shape (since the 2 incomparable elements must have an LUB and a GLB, to
make 4 elements in a diamond shape in the Hasse diagram). Then it only remains to
place the 5th element, which for a lattice can be the greatest element (the 2nd figure),
the least element (the 3rd figure), incomparable to the middle two elements (the 4th
figure), or can occur on a path above or below one of the incomparable elements (the
last figure).


0 0 0 1
 1 1 0 0 

4. (6 pts) Consider the relation R on {1, 2, 3, 4} whose matrix is MR = 
 0 0 0 1 .
1 0 0 0
Use Warshall’s algorithm to compute the matrix of the transitive closure R ∞ . Show
your work.
Solution:

0
 1
W0 = M R = 
 0
1
0
1
0
0
0
0
0
0

1
0 
.
1 
0
To compute W1 , let k = 1 and consider the first row and column of W0 . For the first
row, we have 1’s in (k, j) = (1, 4) only and so j = 4. For the first column, we have 1’s in
(i, k) = (2, 1), (4, 1), so i = 2, 4. So in W1 , we should add 1’s in the (i, j) = (2, 4), (4, 4)
2
slots:

0
 1
W1 = 
 0
1
0
1
0
0
0
0
0
0

1
1 
.
1 
1
Now let k = 2 and consider the second row and column of W1 . For the second row,
we have 1’s in (k, j) = (2, 1), (2, 2), (2, 4), and so j = 1, 2, 4. In the second column,
we have a 1 only in the (i, k) = (2, 2) slot: so i = 2. So our new 1’s are for (i, j) =
(2, 1), (2, 2), (2, 4), which all already have 1’s in them. So


0 0 0 1
 1 1 0 1 

W2 = W 1 = 
 0 0 0 1 .
1 0 0 1
For k = 3, look at the third row and the third column. For the third row we have
(k, j) = (3, 4) only and so j = 4. But there are no 1’s in the third column, so there is
no possible value of i, and no new 1’s in W3 :


0 0 0 1
 1 1 0 1 

W3 = W 2 = W 1 = 
 0 0 0 1 .
1 0 0 1
Finally, consider k = 4. In the fourth row of W3 , there are 1’s in (k, j) = (4, 1), (4, 4),
and so j = 1, 4. The fourth column has all 1’s: so i = 1, 2, 3, 4. Therefore we add 1’s
for the values of (i, j) = (1, 1), (2, 1), (3, 1), (4, 1), (1, 4), (2, 4), (3, 4), (4, 4). Therefore,


1 0 0 1
 1 1 0 1 

MR∞ = W 4 = 
 1 0 0 1 .
1 0 0 1
5. (9 pts) Consider the relation R on A = {1, 2, 3, 4, 5} whose matrix is


1 0 1 1 1
 0 1 1 1 1 


 0 0 1 1 1 .


 0 0 0 1 0 
0 0 0 0 1
(a) Show R is a partial order on A.
Solution: We need to check R is reflexive, antisymmetric, and transitive. To
check R is reflexive, just note that there are all 1’s on the main diagonal. To
check R is antisymmetric, note that there are no matching pairs of 1’s across
the main diagonal. To check transitivity, look at the digraph below. We need
to check that 2R3 ∧ 3R5 ⇒ 2R5, 1R3 ∧ 3R5 ⇒ 1R5, 1R3 ∧ 3R4 ⇒ 1R4, and
2R3 ∧ 3R4 ⇒ 2R4.
3
(b) Draw the Hasse diagram of (A, R).
Solution:
First draw the digraph, as on the left. Then remove the arrows corresponding to
the reflexive loops, and make the remaining arrows all point up. Now erase the
arrows that are made redundant by transitivity to get the third picture. Finally,
turn this picture into a Hasse diagram.
(c) Is the poset (A, R) a lattice? Why or why not?
Solution: No. For example LUB(4, 5) does not exist.
4
6. (20 pts) True/False. Circle T or F. No explanation needed.
For questions (a) and b below, consider the following Hasse diagram of (A, ≤):
(a)
T
F
(b)
T
F
(c)
T
F
(d)
T
F
(e)
T
F
(f)
T
F
(g)
T
F
(h)
T
F
(i)
T
F
(j)
T
F
a ≥ f.
Solution: T.
(A, ≤) is a lattice.
Solution: F. For example, LUB(b, c) does not exist.
For Z the set of integers, there is a function from Z to
Z which is onto but not one-to-one.
Solution: T. For example f (n) = b n2 c is such a function.
Every function from Bn to B1 can be represented as a
Boolean polynomial.
Solution: T.
The lattice (D49 , |) is a Boolean algebra.
Solution: F. The prime decomposition 49 = 72 contains a square.
Warshall’s algorithm, when performed on an n × n bit
matrix, needs Θ(n4 ) steps to be executed.
Solution: F. Warshall’s algorithm takes Θ(n3 ) steps.
If p, q ∈ Z + are distinct prime numbers, then p and q are
comparable with respect to |, the divisibility relation.
Solution: F. Distinct prime numbers are not comparable, since neither p nor q is divisible by the other.
If x, y are Boolean variables, then (x ∨ y)0 = x0 ∧ y 0 .
Solution: T. This is DeMorgan’s Law.
If A, B are sets with |A| = 4 and |B| = 6, then there is
a function from A to B which is onto.
Solution: F. If A only has four elements {a, b, c, d},
then the range of any function f (A) has at most four
elements, since f (A) = {f (a), f (b), f (c), f (c)}.
If A, B are sets with |A| = 4 and |B| = 6, then there is
a function from A to B which is one-to-one.
Solution: T. This can be easily arranged, since for example if A = {a, b, c, d} and B = {1, 2, 3, 4, 5, 6}, then
we can choose a function g satisfying g(a) = 1, g(b) = 2,
g(c) = 3, g(d) = 4, which is clearly one-to-one.
5