Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Name: CSE 1400 Spring 2017 1 Applied Discrete Mathematics Key to Practice Midterm Number Systems 1. (5 pts) What range of natural numbers can be represented using binary strings of length n? Score Answer: The range is 0 to 2n − 1. 2. (5 pts) How many bits needed to represent the natural number n. Score Answer: blg nc + 1 3. (10 pts) Use Horner’s rule to compute the decimal value of the (unsigned) binary number (11110000)2 Score Answer: Answer: Horner’s Rule @ x = 2 1 1 1 1 0 0 0 0 2 6 14 30 60 120 240 1 3 7 15 30 60 120 240 Therefore, (10110100)2 = 240 4. (10 pts) What is the decimal value of the two’s complement number (11110000)2c ? Score Answer: It is 240 − 256 = −16. Notice the negative of (11110000)2c is (00010000)2c = 16. 2 Score Boolean Logic 1. (10 pts) Construct a truth table for the Boolean expression ¬(p ∧ (p ∨ q)) Answer: Input p 0 0 1 1 Score q 0 1 0 1 Output ¬( 1 1 0 0 2. (5 pts) State one of De Morgan’s laws. Answer: There are two: • ¬(p ∧ q) = ¬p ∨ ¬q • ¬(p ∨ q) = ¬p ∧ ¬q 1 p 0 0 1 1 ∧ (p ∨ q)) 0 0 0 1 1 1 1 1 3 Score Sets (9 pts) Let X = {2, 4, 6, 8, 10, 12} and Y = {1, 4, 5, 8, 9, 12} 1. Compute X ∪ Y. Answer: {1, 2, 4, 5, 6, 8, 9, 10, 12} 2. Compute X ∩ Y. Answer: {4, 8, 12} 3. True or False X ∩ Y ⊆ X. Answer: This is True: Every element 4, 8, and 12 in the intersection is also is X. But checking element by element is not necessary. The definition of intersection shows the subset relation. 2 4 Predicate (First–Order) Logic 1. (9 pts) Let canfool(p, t) be the predicate Score “Person p can be fooled at time t.” Use quantifiers (∀, ∃) over the set of people P and the set of time T to write the following sentences. (a) You can fool some of the people all of the time. Answer: (∀t)(∃p)(canfool(()p, t)) This is my interpretation: I don’t think Lincoln was saying there is a “fool,” someone you can always fool. I think he was saying at any given time t there is one or more people you can fool. This statement about the existence of a fool would read (∃p)(∀t)(canfool(()p, t)) (b) You can fool all of the people some of the time. Answer: (∀p)(∃t)(canfool(()p, t)) This is my interpretation: I Lincoln was saying everyone can be fooled sometime. He might also believe there is a time when everyone can be fooled, which would read (∃t)(∀p)(canfool(()p, t)) (c) You cannot fool all of the people all the time. Answer: ¬ [(∀p)(∀t)(canfool(()p, t))] ≡ (∃p)(∃t)(¬canfool(()p, t)) There is always someone who is not fooled at time t. 5 Score Counting (9 pts) The DNA alphabet is DNA = {A, C, G, T } 1. How many DNA strings of length n are there? Answer: There are 4n different DNA strings of length n. 2. A codon three-letter string xyz where x, y, z ∈ DNA. How many codons are there? Answer: There are 43 = 64 different three-letter DNA strings. Note bases can repeat, for instance AAA, ACC are codons. If based do not repeat the answer is 4 · 3 · 2. 3. Codons define amino acids. Nature uses redundancy: several codons can code for the same amino acid. There are 20 naturally occurring amino acids. Proteins are strings of amino acids. How many amino acid strings of length 10 are there? Answer: There are 2010 length 10 amino acid strings. 3 6 Score Sequences (10 pts) List the first five terms in each of these sequences. 1. The Alice sequence Answer: h1, 1, 1, 1, 1 . . .i 2. The Gauss sequence Answer: h0, 1, 2, 3, 4 . . .i 3. The Triangular sequence Answer: h0, 0, 1, 3, 6 . . .i 4. The Mersenne sequence Answer: h0, 1, 3, 7, 15 . . .i 5. The Fibonacci sequence Answer: h0, 1, 1, 2, 3 . . .i 4 7 Score Mathematical Induction 1. (10 pts) Fundamental problem: Use mathematical induction to prove the statement: “the sum of the first n natural numbers is the triangular number tn = n(n − 1)/2.” That is, n−1 X k= k=0 n(n − 1) = 2 n 2 Answer: Basis: When n = 0, no numbers are added in the sum; the sum is empty and defined to be 0. The triangular number t0 = 0(0 − 1)/2 = 0 also. Therefore, the statement is True for n = 0. Implication: If the statement is True for some n, then the sum of the first n + 1 naturals is the sum of the first n naturals plus n, the (n + 1)st natural. (The naturals start with 0, although some will say otherwise.) That is, n X n−1 X k= k=0 ! k +n k=0 n(n − 1) +n 2 n−1 =n +1 2 (n + 1)n = 2 = tn+1 = Score 2. (10 pts) Fundamental problem: Use mathematical induction to prove the statement: “the sum of the first n powers of 2 is mn = 2n − 1.” That is, n−1 X 2k = 2n − 1 k=0 Answer: Basis: When n = 0, no numbers are added, the sum is empty and equal to 0. The expression (30 − 1)/2 = 0 also. Therefore, the equation is True for n = 0. Implication: If the equation is True for some n, then adding in the next term gives n X n−1 X k 2 = k=0 ! k 2 k=0 n + 2n = 2 − 1 + 2n = 2 · 2n − 1 = 2n+1 − 1 5 Score 3. (5 pts) Use mathematical induction to prove n X j = 2−n (−n + 2n+1 − 2) j 2 j=1 Answer: For n = 0 the sum is empty and equal to zero. The function is also equal to 0: 2−0 (−0 + 20+1 − 2) = 1(2 − 2) = 0 Let’s test n = 1: The sum is 1/2 and the function is 2−1 (−1 + 22 − 2) = 1/2 If the summation formula is correct for some value of n ≥ 0, then n+1 X j=1 n X j n+1 j = + n+1 j j 2 2 2 j=1 = 2−n (−n + 2n+1 − 2) + 2−(n+1) (n + 1) = 2−(n+1) (−2n + 2n+2 − 4 + (n + 1)) = 2−(n+1) (−(n + 1) + 2n+2 − 2) Total Points: 107 Wednesday, February 22, 2017 6