CS1800 Discrete Structures Spring 2018 February 2018 CS1800 Discrete Structures Midterm Version A Instructions: 1. The exam is closed book and closed notes. You may not use a calculator or any other electronic device. 2. The exam is worth 100 total points. The points for each problem are given in the problem statement and in the table below. 3. You should write your answers in the space provided; use the back sides of these sheets, if necessary. 4. SHOW YOUR WORK FOR ALL PROBLEMS. 5. You have two hours to complete the exam. Section Title Points Section 1[12 points] Binary and Hexadecimal Section 2 [19 points] Logic Section 3 [21 points] Proofs Section 4 [25 points] Sets and Counting Section 5 [23 points] Permutations and Combinations Total Name: CS1800 (Lecture) Instructor: 1
Section 1 [12 pts: 6,6]: Binary, Octal, and Hexadecimal 1. Write the number 74 in (a) binary, (b) hexadecimal. (a) 1001010 (b) 4A 2. How many digits are in the octal (base 8) representation of 8 4? 5 (don t forget the 8 0 digit) 2
p Section 2 [19 pts: 4,5,2,4,4]: Logic q 1. (a) Write the logic expression that describes the following circuit (do not simplify your expression). p q ( p (p q)) 2 (b) Use logic rules to simplify your expression. Show each step and specify when you are applying the following rules: (1) De Morgan, (2) Distributive, (3) Double Negation. ( p (p q)) (( p p) ( p q)) (F ( p q)) ( p q) (p q) p q distributive law DeMorgan s law double negation (c) Draw the circuit that corresponds to the simplified expression. OR gate 3
2. Simplify the expression q ( p q). Your result should contain only variables and (the smallest possible number of) connectives selected from,,. q ( p q) q ( p q) ( q p) ( q q) ( q p) T ( q p) (q p) 3. Assume x and y are integers, and either explain why the following statement is true, or provide a counterexample: x y : y 2 = x False; if x = 2, for example, there is no integer y that is its square root. 4
Section 3 [21 pts (7 each)]: Proofs 1. A graph G = (V, E) is connected and undirected; a breadth-first search (BFS) traversal finds a path to vertex u of length 3 and finds a path to vertex v of length 7. Prove that the shortest path between u and v has at least 4 edges. If path(u, v) < 4 then a path to v that is shorter than 7 exists, and BFS finds the shortest path contradiction 2. Prove that a tree with n 3 vertices can have at most one vertex of degree n 1. A vertex with degree n 1 (call it A) must be connected to every other vertex. If any of those other vertices (B and C) are connected to each other, then that connection and the two edges out to those vertices forms a cycle (ABC), which is not allowed in a tree. So when one vertex is connected to all the others, none of the others can have any connections to each other, and thus none of them can have degree n 1. Alternate solution: The tree can t have two vertices of degree n 1 as otherwise, together with a third vertex which must have degree at least 1, these would yield a degree sum 2(n 1) + 1 > 2(n 1) and thus a number of edges > n 1, which can t be in a tree. 5
3. Prove by induction that Σ n i=1 4i3 = n 2 (n + 1) 2 for n 1. Base case: Substituting 1 into both sides gives 4=4. Inductive hypothesis: Assume true for n=k, so σi=1 k 4i3 = k 2 (k + 1) 2. Inductive step: For the sum to k + 1, by the inductive hypothesis and adding one more term we have k 2 (k + 1) 2 + 4(k + 1) 3. We can expand the second term a little to get (4k +4)(k +1) 2, which can be combined with the first term to get (k 2 + 4k + 4)(k + 1) 2. Factoring gives (k + 2) 2 (k + 1) 2, and this is clearly the target formula with k + 1 substituted. 6
Section 4 [25 pts: 2,2,2,3,4,3,4,5]: Sets and Counting 1. Consider sets A = {1, 2, 3, 6}, B = {2, 6, 7}, and C = {3, 4, 6, 7}. Use the listing method to describe the following sets (that is, list their elements between braces). (a) A B {1, 2, 3, 6, 7} (b) A B {2, 6} (c) C B {3, 4} (d) (A B) (A C) {2, 6} {3, 6} = {(2, 3), (2, 6), (6, 3), (6, 6)} (e) P(B) (the power set of B). {, {2}, {6}, {7}, {2, 6}, {2, 7}, {6, 7}, {2, 6, 7}} 2. If X = {x x Z, 1 x 1} and Y = {y y R, y 2 = 1}, what is X Y? 3*2 = 6 3. A college class has 81 students. All the students are known to be from 17 through 32 years of age. You want to make a bet that the class contains at least x students of the same age. How large can you make x and be sure to win your bet? There are 32 16 = 16 age groups. The average number of students per age is thus 81/16 = 5+ (slightly larger than 5). As the number of students in each age class is an integer, some age class will contain 6 students. 4. If A = 6, B = 5, and P(A B) = 256, what is A B? (P(A B) is the power set of A B.) From P(A B) = 256 follows that A B = 8. Applying the inclusion-exclusion formula for two sets, we have 8 = A B = A + B A B = 6 + 5 A B. Therefore A B = 3. 7
Section 5 [23 pts (4,3,6,5,5]: Permutations and Combinations Please complete your computations to arrive at a single integer answer for each problem. 1. How many positive divisors does the number 2 3 3 5 5 2 7 have? 4 6 3 2 = 144. 2. Three married couples are going to the movies. (a) In how many ways can the six persons stand in line at the ticket booth, assuming the couples don t need to stay together? 6! = 720 (b) In how many ways can they stand in line at the ticket booth if couples must stay together? order the couples order couple 1 order couple 2 order couple 3 3! = 6 2 2 2 There are 6 2 2 2 = 48 ways to arrange the 6 persons. 3. (a) A test has two sections of five questions each. The instructions say to answer three questions in each section. In how many ways can a student choose the questions to complete the exam? 3 questions from section 1 3 questions from section 2 ( 5 ) ( 3 = 10 5 ) 3 = 10 There are 10 10 = 100 ways to select questions. (b) Another test has three sections of four questions each. According to the instructions, the student must answer two questions from each of any two sections and one question from the other section. In how many ways can the student choose questions to answer? single question section single question 2 quest other section 2 quest last section ( 3 choices 4 choices 4 ) ( 2 = 6 4 ) 2 = 6 There are 3 4 6 6 = 432 ways to select questions. 8