Solutions

Transcription

Solutions
CSC 10400: Discrete Mathematical Structures (Spring 2015)
Midterm 1
Name: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Problem
1
2
3
4
5
6
7
8
9
10
11
Total
Score
There are 11 questions in exam. Each of them is worth 10 points. You can
select 10 of 11 questions. If you answer all of them, the extra question is considered
as a bonus question.
Good Luck!
1
1. In a communication system, a word is formed by 26 capital English letters and 10 digits.
How many different words can we have if
(a) every word consists of either two English letters, or two digits (the word cannot
contain both English letters and digits)?
Answer:
If the word consists of two English letters, we can choose one of 26 letters in the
first position. Similarly, we have 26 choices for the second position. By the rule of
product, there are 26 × 26 = 676 words consisting of two English letters.
If the word consists of two digits, we can choose one of 10 digits in the first position,
and one of 10 digits in the second position. Thus, we there are 10 × 10 = 100 words
consisting of two digits.
Therefore, by the rule of sum, there are 676 + 100 = 776 words.
(b) every word consists of four symbols (can be letters or digits), in which no symbol
occurs more than once?
Answer:
There are 36 choices for the first position. Because no repetition is allowed, there
are 35, 34, and 33 choices for the second, third and the fourth position respectively.
36!
Thefore, by rule of sum, there are 36 × 35 × 34 × 33 = P (36, 4) = (36−4)!
= 36!
32! =
1, 413, 720 words.
2. There are 15 male students and 12 female students in Professor Powell’s class. Professor
Powell want to give 7 distinct C++ books to male students and 5 distinct Java books to
female students. In how many ways can the professor give these books to students if
(a) every student has at most one book?
Answer:
Because every student has at most one book, and because the number of books is
less than the number of students, we can choose students as the recipients of these
books without repetition. However, because the books are distinct, the order should
be considered. This is the problem of permutation.
We can choose 7 from 15 male students to receive C++ books. When the order
is considered, there are P (15, 7) = 15!
8! ways to choose male students. Similary, we
12!
have P (12, 5) = 7! ways to choose female students.
Therefore, by rule of product, there are
15!12!
8!7!
ways in total.
(b) there is no restrictions?
Answer:
Because there is no restriction, the professor can choose the receiver for each book
with repetition. This is the problem of permuation with repetition.
There are 157 ways to choose 7 males students to receive C++ books with repetition.
Similarly, there are 125 ways to receive Java books with repetition.
Therefore, by rule of product, there are 157 × 125 ways to give books.
2
3. Write out the truth table for each of the following statement, and determine whether the
statement is a tautology, a contradiction, or neither a tautology nor a contradiction.
(a) (¬p ∨ q) ∧ (p ∨ ¬q).
Answer:
The truth table is shown as follows.
p
0
0
1
1
q
0
1
0
1
¬p
1
1
0
0
¬q
1
0
1
0
¬p ∨ q
1
1
0
1
p ∨ ¬q
1
0
1
1
(¬p ∨ q) ∧ (p ∨ ¬q)
1
0
0
1
Therefore, the statement is neither a tautology nor a contradiction.
(b) (p → q) ∨ (q → p).
Answer:
The truth table is shown as follows.
p
0
0
1
1
q
0
1
0
1
p→q
1
1
0
1
q→p
1
0
1
1
(p → q) ∨ (q → p)
1
1
1
1
Therefore, the statement is a tautology.
4. Write the inverse, converse, and the contrapositive of the following statement in English.
If Leonard published a paper, then Sheldon published a book.
Answer:
We use p to denote “Leonard published a paper”, and use q to denote “Sheldon published
a book”. Then, the original setence can be rewritten as p → q.
• Inverse: (¬p → ¬q)
If Leonard did not publish a paper, then Sheldon did not published a book.
• Converse: (q → p)
If Sheldon published a book, then Leonard published a paper.
• Contrapositive: (¬q → ¬p)
If Sheldon did not publish a book, then Leonard did not publish a paper.
3
5. Use the rule of inference to prove the validity of the following argument.
∴
p→s
q→r
s→t
p∨q
¬t
r
Answer:
The validity of this argument can be proved as follows.
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
p→s
q→r
s→t
p∨q
¬t
¬s
¬p
q
∴r
Premise
Premise
Premise
Premise
Premise
(3)(5), Modus Tollens
(1)(6), Modus Tollens
(4)(7), Rule of Disjunctive Syllogism
Modus Ponens
6. Let F (x, y) be the open statement “x can fool y” where the domain consists of all people
in the world. Use quantified open statements to express each of the following statements.
(a) Everyboday can fool somebody.
Answer:
∀x∃y : F (x, y).
(b) No one can fool everybody.
Answer:
¬∃x∀y : F (x, y) or ∀x∃y : ¬F (x, y).
7. Negate the following open statements and simplify the negated statements so that the
negation operators must be within predicates (that is,no negation is outside a quantifier
or an expression involving logical connectives).
(a) ∀x∃y : P (x, y).
Answer:
¬∀x∃y : P (x, y)
⇔∃x¬∃y : P (x, y)
⇔∃x∀y : ¬P (x, y)
4
(b) ∃x∀y∃z : (P (x, y) → (Q(x, y) ∧ ¬R(x, y, z))).
Answer:
¬∃x∀y∃z : (P (x, y) → (Q(x, y) ∧ ¬R(x, y, z)))
⇔∀x¬∀y∃z : (P (x, y) → (Q(x, y) ∧ ¬R(x, y, z)))
⇔∀x∃y¬∃z : (P (x, y) → (Q(x, y) ∧ ¬R(x, y, z)))
⇔∀x∃y∀z : ¬(P (x, y) → (Q(x, y) ∧ ¬R(x, y, z)))
⇔∀x∃y∀z : ¬(¬P (x, y) ∨ (Q(x, y) ∧ ¬R(x, y, z)))
⇔∀x∃y∀z : P (x, y) ∧ ¬(Q(x, y) ∧ ¬R(x, y, z)))
⇔∀x∃y∀z : P (x, y) ∧ (¬Q(x, y) ∨ R(x, y, z)))
8. Let A = {1, 3, 5}, and B = {1, 2, 3, 4}.
(a) Write down A ∩ B and A − B.
Answer:
A ∩ B = {1, 3}, A − B = {5}.
(b) Let C = A ∪ B. How many subsets of C contain odd number of elements?
Answer:
C = A ∪ B = {1, 2, 3, 4, 5}. If the subset of C contains exactly one element, we
have to choose 1 from 5 elements in C as the element in the subset. Thus, there
are 51 subsets of C containing exactly 1 element. Similarly, there are 53 and 55
subsets of C containing exactly 3 and 5 elements, respectively. Therefore, there are
5
5
5
5−1 = 24 = 16 subsets of C containing odd number of elements.
1 + 3 + 5 =2
9. Complete the following table by filling “True” or “False” in the blank cells.
A
∅
{1}
B
{∅}
{{1}}
A∈B
A⊆B
A⊂B
A=B
|A| = |B|
A⊆B
True
False
A⊂B
True
False
A=B
False
False
|A| = |B|
False
True
Answer:
The answer is listed as follows.
A
∅
{1}
B
{∅}
{{1}}
A∈B
True
True
5
10. Let A, B and C be sets in a given universe U . For each of the following, draw the Venn
diagram, and point out which area corresponds to the given set.
(a) A ∩ B ∩ C.
Answer:
U
A
B
C
(b) A ∩ (B − C).
Answer:
U
A
B
C
11. There are 300 students in the Deparment of Computer Science. Among these students,
189 students know C++, 167 students know Java, 154 students know Python, 96 students
know both C++ and Java, 110 students know both Java and Python, 85 students know
both C++ and Python, and no one knows the fourth programming language. How many
students know all of three programming languauges?
Answer:
Let A be the set of students knowing C++, B be the set of students knowing Java, and
C be the set of students knowing Python. We have
|A| = 189
|A ∩ B| = 96
|A ∪ B ∪ C| = 300
|B| = 167
|B ∩ C| = 110
6
|C| = 154
|A ∩ C| = 85
Because |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|. We
have
|A ∩ B ∩ C| = |A ∪ B ∪ C| − |A| − |B| − |C| + |A ∩ B| + |A ∩ C| + |B ∩ C|
= 300 − 189 − 167 − 154 + 96 + 85 + 110
= 81
Therefore, there are 81 students knowing all of three programming languages.
7