CS 310 Review Sheet Answers

advertisement
CS 210 Review Sheet
1. What is the negation of x P(x)?
Answers.
Spring 2012
x (P(x))
2. State the inverse, converse and contrapositive of the statement: “If m divides n and n divides
p, then m divides p”.
Inverse: If m does not divide n or n does not divide p, then m does not divide p
Converse: If m divides p then m divides n and n divides p
Contrapositive: If m does not divide p then m does not divide n or n does not divide p
3. Always, Sometimes or Never: A  (B  C) and B  (A  C) are disjoint.
4. What is |A  B  C| if |A| = |B| = |C| = 90, |AB| = |AC| = |BC| = 50 and |ABC| = 25?145
5. How many subsets of size six does a set with 15 elements have? C(15, 6)
6. How many strings of length six can be formed from a 15 letter alphabet?
a. with repetition allowed? 156
b. with all letters distinct? P(15, 6)
7. Suppose A B and C D. Prove or disprove: (A  C)  (B  D).
Let x  A  C. then x  A and x  C by definition of intersection.
Since x  A and A  B, then x  B by definition of subset.
Since x  C and C  D, then x  D by definition of subset.
Therefore, x  B D
8. A sailing club has 10 white flags, 7 red flags, and 3 green flags. If all flags are displayed on
a flag pole, how many different arrangements are possible? 20!/(10!•7!•3!)
9. Let S = {1,2,3,4,5,6,7,8,9,10}.
a. In how many 5-element subsets of S is 3 the smallest element?
C(7, 4) There are seven elements greater than three of which four must be chosen to
obtain a subset of size five that includes 3.
b. How many subsets contain only prime numbers?
24 – 1 since there are four prime numbers in the set. You must subtract 1 for the .
c. How many subsets contain exactly two odd numbers?
There are C(5,2) ways to choose the odd numbers and 2 5 subsets of the set of even
numbers in S so the answer is C(5,2)•25.
d. How many subsets of size six contain exactly two odd numbers?
Two odd numbers and four even numbers—C(5, 2)•C(5, 4)
10. How many five card poker hands have exactly 2 pairs? C(13, 2)C(4, 2)C(4, 2)44
11. A five-card hand is selected from a deck of 52 cards. How many hands contain
a. no aces or kings? C(44, 5)
b. exactly 2 queens? C(4, 2)•C(48, 3)
c. exactly 2 queens and exactly 3 spades?
C(3, 2)•C(12, 3) + C(3, 1)•C(12, 2)•36 (without and with the Q of spades)
12. A string of length 8 is formed from the alphabet A = {a, b, c, d, e, f, g}. How many strings
a. contain exactly one a or exactly two b’s?
(exactly 1 a + exactly 2 b’s – 1a and 2b’s)
8•67
+
C(8,2)•66 - 8•C(7, 2)•55
b. contain four of one letter, all consecutive, and all remaining letters distinct?
7 ways to choose the letter of which there are 4, 5 places to put the four consecutive
letters and 6•5•4•3 ways to place the remaining letters or 7•P(6,4)
13. A pizza take-out advertises it offers a choice of over 200 different pizzas. You can choose
one or more different toppings. How many toppings must be available to make this
statement true? 8 since 28 = 256 and 27 = 128
14. How many distinct permutations are there of the letters in CORPORATION? 11!/ (3!•2!)
15. f: R  R, what is the range of the function f(x) = 1/(x2 + 4)? all y such that 0 < y  ¼
n
16. Write the following using  notation n + (n-1)/2! + (n-2)/3! + (n-3)/4! + … + 1/n!  (n-i+1)/i!
i=1
40
17. Given that 12 + 32 + ... + (2n – 1)2 = n(2n - 1)(2n + 1)/3 , find (2i – 1)2 40·79·27 - 14·9·29
i=15
18. Construct the truth table for the following statement. Is it a tautology, contradiction, or
neither? q  (p  q)  p
This is a tautology
p q pq q q  pq p
q  pq  p
T T
T
F
F
F
T
T F
F
T
F
F
T
F T
T
F
F
T
T
F F
T
T
T
T
T
19. A = {1, 2} and B = {a, b}. Show all functions from A to B. For each one, tell if it is one-to-one
and/or onto. How many relations are there from A to B?
f1(1) = a
f2(1) = a
f3(1) = b
f4(1) = b f2 and f3 are one-to-one and onto
f1(2) = a
f2(2) = b
f3(2) = a
f4(2) = b There are 24 relations.
20. Prove or disprove: If f  g is onto then g is onto. Not true
Let A = {1, 2}, B = {3, 4, 5} and C = {a} where g(1) = g(2) = 3 and f(3) = f(4) = f(5) = a
21. Use mathematical induction to prove that 6 | (n3 + 5n) for n  1.
Basis: n = 1, n3 + 5n = 1 + 5´1 = 1 + 5 = 6 and 6 | 6 so P(1) holds.
Hypothesis: 6 | (n3 + 5n) for n  1
Induction Step: (n+1)3 + 5(n+1) = n3 +3n2 +3n + 1 + 5n + 5 =
n3 + 5n + 3(n2 + n + 2)
By hypothesis 6 | n3 + 5n
3 | 3(n2 + n + 2) and (n2 + n + 2) is even, so 6 | 3(n2 + n + 2)
Therefore, 6 | n3 + 5n + 3(n2 + n + 2)
22. Using the definition of Big O, prove that (x2 + 4x + 5)  O(x3).
x2 + 4x + 5  x3 + 4x3 + 5x3 = 10x3
Thus, let K = 10 and N = 1. Then, by the definition of big-O, x2 + 4x + 5 = O(x3)
35
23. Evaluate the following summation  (4i – 2)
i=10
(436 – 410)/3 – 2•26
24. Solve the following recurrence f(n) = 8f(n/2) + 3 and f(1) = 3. Assume n = 2k. 3n3 + 3(n3-1)/7
25. How many bit strings of length 8 begin with 101 or have a 1 as the fourth bit? 25 + 27 - 24 = 144
26. A binary relation R on the set of integers is defined by (a, b)  R iff ab  0. Prove or
disprove: R is an equivalence relation. What is R-1?
For any integer a, a•a  0, so (a, a)  R and R is reflexive.
If (a, b)  R then a•b  0. Thus, b•a  0 and (b, a)  R and R is symmetric.
R is not transitive since (2, 0)  R and (0, -5)  R but (2, -5)  R since 2(-5) = -10
(a, b)  R-1 iff ba  0 so R-1 = R
27. Find the value of k if f(n + 1) = k f(n), f(1) = 5 and f(3) = 20
k = 2 or k = -2
28. If f(n) = f(n/3) + 2n and f(1) = 1 find f(27). f(27) = 79
29. Let R be a reflexive, transitive relation on a set X. Show that R  R-1 is an equivalence relation.
R  R-1 is reflexive since a  X, (a, a)  R. By the definition of inverse, (a, a)  R-1
and thus (a, a)  R  R-1. If (a, b)  R  R-1 then (a, b)  R and (a, b)  R-1. Therefore,
by the definition of inverse, (b, a) is in both R and R-1 and thus R  R-1 is symmetric.
Finally, suppose both (a, b) and (b, c) are in R  R-1. Then, both (a, b) and (b, c) are
in R and also in R-1. Since R is transitive, (a, b) and (b, c) in R imply (a, c)  R. By
the definition of inverse, (b, a) and (c, b) are in R. Since R is transitive, (c, a)  R and
thus (a, c)  R-1. This means (a, c)  R  R-1 and thus R  R-1 is transitive.
30. Find the number of bit strings with five 0's and eight 1's that contain the substring 0101.
10•C(9, 3) (Arrange 10 things: the 0101 pattern + three 0's and six 1's)
31. A test has two parts. Part 1 has 6 questions and part 2 has 4. A student must answer a
total of 6 questions with at least two from each part. In how many ways can the questions
that are answered be selected? C(6, 2)•C(4, 4) + C(6, 3)•C(4, 3) + C(6, 4)•C(4, 2)
32. Find an integer a > 7 such that a 7 3a. One possible answer is a = 14.
33. Prove or disprove: If a m b, and if c m d then ac m (b + d).
False. Here's one counterexample: a = 5, b = 5, c = 2, d = 2, and m = 5
34. Prove that (pq) is logically equivalent to p V q.
q
p V q
p
q
pq pq) p
T
T
T
F
F
F
F
T
F
F
T
F
T
T
F
T
F
T
T
F
T
F
F
F
T
T
T
T
35. Prove or disprove: if R1 and R2 are equivalence relations, then so is R1  R2
Not necessarily since the union may not be transitive. Let S = {1, 2, 3} and
R1 = {(1,1), (2, 2), (3, 3), (1,2), (2, 1)} and let R2 = {(1,1), (2, 2), (3, 3), (2,3), (3, 2)}.
To be transitive (1,3) would have to be in the union.
36. For integers a, b define a relation R on A by (a, b)  R iff 2a+ 3b = 5n for some integer n.
Prove that R is a reflexive, symmetric relation on Z.
Given a  A, 2a + 3a = 5a, so (a, a)  R and R is reflexive
If (a, b)  R then 2a + 3b = 5k so b = (5k – 2a)/3 which is an integer. Now, consider
2b + 3a = 2((5k – 2a)/3) + 3a where both terms are integers so the sum is an integer.
Simplifying and putting everything over a common denominator we get (10k – 4a +
9a)/3 = 5(2k + a)/3 so (b, a)  R and R is symmetric.
37. What properties does the following relation possess?
R = {((a, b), (c, d)) | a + b  c + d} For example, ( (2, 3), (4, 1) )  R That is, the elements of R
are pairs of ordered pairs
Reflexive ( (a,b), (a,b) )  R for all pairs (a, b)
Antisymmetric If a + b  c + d and c + d  a + b then a + b = c + d
Transitive If ( (a,b), (c,d) ) and ( (c,d), (e,f) )are in R then a + b  c + d and c + d  e + f,
then a + b  e + f. Therefore ( (a,b), (e,f) )  R so R is transitive.
38. If a relation is reflexive, its inverse is (always, sometimes, never) reflexive.
39. If a relation is reflexive, its complement is (always, sometimes, never) reflexive.
40. Suppose |A| = n and that R is an antisymmetric relation on A. What is maximum value of |R|?
(n2 + n)/2—a largest antisymmetric relation will be obtained by choosing all ordered pairs
above and on the diagonal.
41. If R = {(1, 3), (2, 1), (2, 3), (3, 2), (4, 2)} is a relation on S = {1, 2, 3, 4}, find the transitive
closure of R.
{(1, 3), (2, 1), (2, 3), (3, 2), (4, 2), (1, 2), (2, 2), (3, 1), (3, 3), (4, 1), (4, 3), (1, 1)}
42. The set { {1, 3, 5}, {2}, {4, 6} } is a partition of S = {1, 2, 3, 4, 5, 6}. List all ordered pairs in the
corresponding equivalence relation.
{(1, 1), (1, 3), (1, 5), (3, 1), (3, 3), (3, 5), (5, 1), (5, 3), (5, 5), (2, 2), (4, 4), (4, 6), (6, 4), (6, 6)}
43. For each relation below, place its number in the blank to the left of each property it satisfies.
Relation 1: R = {(a, b) N  N | a + b is even}
Relation 2: R = {(a, b) | a, b  Z and |a - b|  1}
Relation 3: R = 
_____1, 2_____ Reflexive ___1, 2, 3_____ Symmetric __1, 3_______ Transitive
______3______ Irreflexive _____3_____ Antisymmetric ____3______ Asymmetric
44. Suppose you have a seven-card hand. How many hands satisfy each of the following?
a. The hand contain exactly five red cards and two black cards that are a pair.
C(26, 5)•13 (13 ranks to get the pair from.
b. The hand contains three hearts and three kings.
C(3,2)•C(12, 2)•C(36,2) + C(12,3)•C(3,3)•36
c. The hand contain no two cards of the same rank.
C(13,7)•[C(4,1)]7
d. The hand contains cards of exactly one suit. 4•C(13,7)
e. The hand contains cards of exactly one color. 2•C(26,7)
f. The hand contains 3 cards of one rank, two cards each of two other ranks.
13•C(4,3)•C(12,2)•[C(4,2)]2
g. The hand contains 3 cards of one rank, two cards each of two other ranks and no face cards.
10•C(4,3)•C(9,2)•[C(4,2)]2
45. How many distinct factors does the number 24•52•75 have?
5•3•6—You may choose from 0 to four 2’s (5 choices), 0 to two 5’s and 0 to five 7’s
Download