Midterm Exam 1 Solution - Discrete Structures | CS 173, Exams of Discrete Structures and Graph Theory

Material Type: Exam; Class: Discrete Structures; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 2008;

Typology: Exams

Pre 2010

Uploaded on 03/16/2009

koofers-user-w2j
koofers-user-w2j 🇺🇸

4

(1)

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS173 Midterm 1 Solutions Spring 2008
CS173: Discrete Mathematical Structures, Spring 2008
First Midterm Solutions
Course Questions
0. The easy problem:
(a) [1 point] How many homeworks are you allowed to drop?
Solution: Two.
(b) [1 point] What is the penalty for submitting late homework?
Solution: No credit.
(c) [1 point] What percentage of your course grade is devoted to discussion section partic-
ipation?
Solution: 10%.
(d) [2 points] Circle the sources of information that you are not allowed to use while
working on CS173 homework.
i. The CS173 website.
ii. Discussions with your friend Sarah who took CS173 last semester.
iii. A textbook (other than the course text by Ensley and Crawley).
iv. A brainstorming session with Josh, who is also taking CS173.
v. A draft of the homework solutions that Josh produced after the brainstorming ses-
sion.
vi. Your section leader.
vii. Wikipedia (a freely available online encyclopedia).
Solution: (ii), (iii), (v), (vii)
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Midterm Exam 1 Solution - Discrete Structures | CS 173 and more Exams Discrete Structures and Graph Theory in PDF only on Docsity!

CS173: Discrete Mathematical Structures, Spring 2008

First Midterm — Solutions

Course Questions

  1. The easy problem:

(a) [1 point] How many homeworks are you allowed to drop? Solution: Two. 

(b) [1 point] What is the penalty for submitting late homework? Solution: No credit. 

(c) [1 point] What percentage of your course grade is devoted to discussion section partic- ipation? Solution: 10%. 

(d) [2 points] Circle the sources of information that you are not allowed to use while working on CS173 homework. i. The CS173 website. ii. Discussions with your friend Sarah who took CS173 last semester. iii. A textbook (other than the course text by Ensley and Crawley). iv. A brainstorming session with Josh, who is also taking CS173. v. A draft of the homework solutions that Josh produced after the brainstorming ses- sion. vi. Your section leader. vii. Wikipedia (a freely available online encyclopedia).

Solution: (ii), (iii), (v), (vii) 

Multiple Choice (5 points each)

Indicate your answers by circling the correct one. Each question has exactly one correct answer. Read everything carefully.

  1. What is the size of P(P(∅)) × P({ 1 , 2 , 3 })? (Recall that we use P(A) to denote the powerset of a set A, and ∅ to denote the empty set.)

(a) 64 (b) 32 (c) 16 (d) 8 (e) 6

(f) 4 (g) 2 (h) 1 (i) 0 (j) None of the above.

Solution: (c).

|P(P(∅)) × P({ 1 , 2 , 3 })| = |P(P(∅))| · |P({ 1 , 2 , 3 })| = 2|P(∅)|^ · 2 |{^1 ,^2 ,^3 }| = 2^2 |∅| · 23 = 2^2 0 · 8 = 2^1 · 8 = 16



  1. Read carefully. Let X = { 4 , 8 , 15 , 16 , 23 , 42 }. Which of the following is a partition of X?

(a) ({ 4 , 16 }, { 8 , 15 , 23 }, { 42 }) (b) {{ 4 , 16 , 42 , 4 }, { 15 }, { 8 , 23 }} (c) {(4, 8 , 16), (15, 23 , 42)} (d) { 4 , 8 , 15 , 16 , 23 , 42 } (e) None of the above.

Solution: (b). Because { 4 , 16 , 42 , 4 } = { 4 , 16 , 42 }, the element 4 appears in exactly one of the sets in option (b). 

  1. Which of the following is the converse of the statement, “You are crazy if you are taking CS 173.”

(a) If you are crazy, then you are taking CS173. (b) If you are not taking CS 173, then you are not crazy.

(f) There is an honest politician. (g) There is a dishonest politician.

(h) None of the above.

Solution: (b). In English, if it is not true that every dishonest person is a politician, then there must be some person x who is a counterexample to the implication “x is dishonest implies x is a politician”. To be a counterexample, x must be both dishonest and not a politician. Using formal logic, this reasoning is expressed as follows.

¬ (∀x ∈ S, ¬A(x) → B(x)) = ∃x ∈ S, ¬ (¬A(x) → B(x)) = ∃x ∈ S, ¬ (¬(¬A(x)) ∨ B(x)) = ∃x ∈ S, ¬ (A(x) ∨ B(x)) = ∃x ∈ S, (¬A(x) ∧ ¬B(x))



Short Answer

Write your solutions in the space provided.

  1. [8 points] Fill in the blanks.

(a) Every proof by induction is an argument that there can be no minimum counterexample (2 words). (b) A proof by induction consists of three parts: the introduction (e.g. “The proof is by induction on n.”), the base case (2 words), and the inductive step. (2 words). (c) The inductive hypothesis (2 words) allows us to assume that theorem holds for all smaller inputs than the one we are presently considering.

  1. [12 points] Express the following sets as simply as you can. Use explicit lists for finite sets. For infinite sets, use set builder notation (both “form description” and “property description” answers are acceptable). Let A = {n ∈ Z : n is even}, B = {n ∈ { 2 , 3 , 4 ,.. .} : n is prime}, C = {n^2 : n ∈ Z}, and D = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }.

(a) B ∩ C Solution: Because no number is both a prime and a perfect square, B ∩ C = ∅.  (b) C − A Solution: Note that C consists of all perfect squares and A consists of all even numbers. Therefore C − A consists of all odd perfect squares, and so C − A = {n^2 : n is odd}.  (c) (B ∩ D) × (A ∩ C ∩ D) Solution: Let’s solve this piece by piece. First, we have that B ∩ D is the set of all primes p in the range 0 ≤ p ≤ 9, and so B ∩ D = { 2 , 3 , 5 , 7 }. Second, we have that

A ∩ C ∩ D is the set of all even perfect squares m in the range 0 ≤ m ≤ 9, and so A ∩ C ∩ D = { 0 , 4 } (note that 0 = 0 · 0, so 0 ∈ C). Putting these pieces together, we get

(B ∩ D) × (A ∩ C ∩ D) = { 2 , 3 , 5 , 7 } × { 0 , 4 } = {(2, 0), (3, 0), (5, 0), (7, 0), (2, 4), (3, 4), (5, 4), (7, 4)}.

 (d) P(D ∩ C ∩ A) ∪ P((D ∩ C) − A) Solution: Again, let’s solve this piece by piece. We’ve already seen in part (c) that D ∩ C ∩ A = A ∩ C ∩ D is just { 0 , 4 }. Also, D ∩ C consists of all elements that are perfect squares m in the range 0 ≤ m ≤ 9, so that D ∩ C = { 0 , 1 , 4 , 9 }. To get (D ∩ C) − A, we must remove from D ∩ C elements which are even, so (D ∩ C) − A = { 1 , 9 }. Putting these pieces together, we get

P(D ∩ C ∩ A) ∪ P((D ∩ C) − A) = P({ 0 , 4 }) ∪ P({ 1 , 9 }) = {∅, { 0 }, { 4 }, { 0 , 4 }} ∪ {∅, { 1 }, { 9 }, { 1 , 9 }} = {∅, { 0 }, { 4 }, { 0 , 4 }, { 1 }, { 9 }, { 1 , 9 }}



  1. [10 points] Count the number of integers in { 0 , 1 , 2 ,... , 500 } which are divisible by 4 or 5.

Solution: Let U = { 0 , 1 ,... , 500 }. We use inclusion/exclusion to count the number of elements in the universe U that are divisible by 4 or 5. Let

A = {n ∈ U : n is divisible by 4} B = {n ∈ U : n is divisible by 5}

and note that we wish to compute |A ∪ B|. By inclusion/exclusion, we have that |A ∪ B| = |A| + |B| − |A ∩ B|. Excluding 0, there are 500/4 = 125 multiples of four in U ; including 0, we have there are 126 multiples of 4 in U , so |A| = 126. Similarly, excluding 0, there are 500 /5 = 100 multiples of 5 in U , and so |B| = 101. A number is in A ∩ B if and only if it is divisible by 4 and 5; because 4 and 5 share no common divisors except 1, a number n is divisible by 4 and 5 if and only if n is divisible by 4·5 = 20 (think about the prime factorization of n). Excluding 0, there are 500/20 = 25 multiples of 20 in U , and so |A ∩ B| = 26. We compute |A ∪ B| = |A| + |B| − |A ∩ B| = 126 + 101 − 26 = 201. 

  1. [10 points] Let n ≥ 1 be an integer and let U = { 1 , 2 ,... , n}. Prove or disprove:

(a) ∀(x, y) ∈ U × U, ((x − y) ∈ U ) ∨ ((y − x) ∈ U ) Solution: This is false. We argue that (x, y) = (1, 1) is a counterexample. Indeed, x − y = y − x = 0, and by definition of U , we have that 0 6 ∈ U. Therefore the statement that x − y or y − x is in U fails for (x, y) = (1, 1).  (b) ∀A ∈ P(U ), ∃B ∈ P(U ), (A ∪ B = U ) ∧ (A ∩ B = ∅)

(b) This solution uses induction on n. If n = 1, then U = { 1 , 2 , 3 }, and because S contains 2 n+1 = 3 elements, it must be that S = { 1 , 2 , 3 }. Therefore S contains three consecutive integers. Inductive step: let n ≥ 2. The inductive hypothesis states that for each 1 ≤ r < n, every subset T of { 1 , 2 ,... , 3 r} of size 2r + 1 contains 3 consecutive numbers. We consider two cases. In the first case, if 3n − 2 , 3 n − 1 , 3 n are all elements of S, then S contains 3 consecutive numbers and we are done. In the second case, S contains at most 2 of the largest three numbers of U. Because S contains 2n + 1 numbers and at most 2 of them are among the largest three numbers of U , there must be at least (2n + 1) − 2 = 2(n − 1) + 1 elements of S among the other, smaller numbers. Therefore there exists a set T ⊆ S ∩ { 1 , 2 ,... , 3(n − 1)} with size 2(n − 1) + 1. By the inductive hypothesis with r = n − 1, we have that T contains 3 consecutive elements. Because T ⊆ S, it must be that S also contains three consecutive elements.



  1. Prove by induction that any positive integer can be written as a sum of distinct powers of 2. ‘Distinct’ means that each power of 2 appears at most once in the sum. For example:

4 = 2^2 17 = 2^4 + 2^0 23 = 2^4 + 2^2 + 2^1 + 2^0 173 = 2^7 + 2^5 + 2^3 + 2^2 + 2^0

In other words, prove that any positive integer can be written in binary!

Solution: First, a few comments. Our solution is almost exactly the same as the solution to the Fibonacci sum problem on homework 3. Much like the problem on HW3, we greedily subtract the largest power of 2 that is at most n from n and apply the inductive hypothesis to whatever remains. Many students gave answers which applied the inductive hypothesis to n − 1 and then attempted to add 2^0 = 1. The problem is that if n − 1 is odd, then 2^0 will appear in the sum for n − 1 and we are not allowed to use 2^0 again. Several students noticed this problem and observed that we can combine the two copies of 2^0 to form a single copy of 2^1. Of course, it may be the case that 2^1 also appears in the sum for n − 1. At this point, these solutions typically say something along the lines of “continue to combine these powers of two” or use the phrase “and so on”. A proof cannot be vague. A proof cannot show the reader how to do the first few steps and then wish the reader well in figuring out what to do next, even if it seems completely obvious. There are many “obvious” mathematical statements that turn out, after careful thought, to be quite subtle or simply outright false. In this particular case, these solutions make the assumption that eventually, somehow we will be able to remove all duplicate powers of two from the sum for n. First, to be correct, such solutions must precisely define the procedure by which all duplicate powers of two can be removed. This definition can be as simple as “While our sum for n uses duplicate powers of two, choose an arbitrary power of two 2k^ that appears at least twice and replace two copies of 2 k^ with a single copy of 2k+1”, but it must be there. Next, to be correct, such solutions must prove that the given procedure terminates with an expression of n as a sum of distinct powers of two. For example, we can prove that this procedure works by induction on the number of terms used in the sum; because each iteration removes two old terms and introduces one new

term, the number of terms is reduced by 1 in each iteration. Again, it may seem obvious to you that this procedure will work, but you must still offer a proof. The good news is that if it really is obvious that the procedure will work, then it should be (relatively) easy for you to write down the proof.

Note that our proof provides the reader from start to finish with instructions for expressing a given number n as a sum of distinct powers of two. If your solution does not do the same, it is a good sign that it is incomplete.

Proof: by induction on n. If n = 1, then 1 = 2^0 , so 1 can be expressed as a sum of distinct powers of two and the statement holds for n = 1.

Inductive step: let n ≥ 2. The inductive hypothesis states that each number 1 ≤ x < n can be expressed as a sum of distinct powers of two. Let 2k^ be the largest power of two that is at most n, so that 2k^ ≤ n but 2k+1^ > n. Let x = n − 2 k. Because n ≥ 2, we have that 2 k^ ≥ 2, and so subtracting 2k^ from n gives a smaller number, and therefore x < n. Because 2 k^ ≤ n, we have that x ≥ 0. If it happens that x = 0, then n = 2k^ expresses n as a sum of a single power of two and we are done. Otherwise, we have that 1 ≤ x < n, and therefore by the inductive hypothesis, x can be expressed as a sum of distinct powers of two.

We would like to obtain n = 2k^ + x as a sum of distinct powers of two by simply adding 2k to our expression of x as a sum of distinct powers of two. The problem is that if 2k^ is used in the sum for x, we will not have expressed n as a sum of distinct powers of two. We solve this problem by arguing that 2k^ is not used in the sum for x.

To prove that 2k^ is not used in the sum for x, we show that x < 2 k. Suppose for a contradiction that x ≥ 2 k. It follows that n = 2k^ + x ≥ 2 k^ + 2k^ = 2k+1. But n ≥ 2 k+ contradicts that 2k+1^ > n.

Therefore 2k^ is not used in the sum for x and we may add 2k^ to the sum for x to express n = 2k^ + x as a sum of distinct powers of two.