CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 15, 2017 CS1800 Discrete Structures Final Version B 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 [11 points] Binary and Other Bases Section 2 [12 points] Logic and Circuits Section 3 [12 points] Modular Arithmetic and Algorithms Section 4 [10 points] Sets and Set Operations Section 5 [10 points] Counting Section 6 [14 points] Probability Section 7 [15 points] Algorithms, Recurrences, Growth of Functions Section 8 [16 points] Proofs Total Name: CS1800 (Lecture) Instructor: 1
Section 1 [11 pts (4,3,4) ]: Binary and Other Bases 1. Add the 8-bit two s complement numbers 11010111 and 01010101. Give the binary and interpret your result as a decimal integer. 2. What is the minimum number of bits necessary to represent the number -18 in two s complement? 3. Give the hex representation of the decimal number 25600. Hint: Write the number as a product of familiar numbers. 2
Section 2 [12 pts (2,3,4,3)]: Logic and Circuits 1. What is the name of the logic gate that is true iff at least one input is true? 2. Write a formula in conjunctive normal form that is true iff at least one of a, b, or c is true, and at least one of b, c, or d is false. You must use the operators,, and. 3. Draw a circuit that takes a three-bit binary number a 2 a 1 a 0 as input (a 0 is the least significant bit), and returns true precisely when the number is divisible by 4. Don not use more than three gates. 4. Simplify the expression (a b) ( a ( b a)). 3
Section 3 [12 pts (4, 4, 4)]: Modular Arithmetic and Algorithms 1. Let y = (7 x + 4) mod 23 be a linear cipher. (a) Use the Extended Euclidean Algorithm to determine the multiplicative inverse of 7 (mod 23). (b) If y = 10 was the message received, determine the message x that was sent. Your answer should be an integer in the range 0 x < 23. 2. Consider the RSA public key (4, 33). Calculate the totient function φ(n), then describe what is wrong with the key. 4
Section 4 [10 pts (3,4,3)]: Sets and Set Operations For the following problems, let A = {a, b, c}, B = {b, c, d}, C = {d, e, f, g}, with universe U = {a, b, c, d, e, f, g}. 1. Write out the set that results from the operations (A B). 2. How many elements are in P(P(A B))? 3. If D = {x x N, 1 x 2 9}, what is D? 5
Section 5 10 pts (4,6): Counting For these problems, we expect your answers to be simplified into integers for full credit. 1. A contest is held among 20 people and there are three possible outcomes: a single person is declared the winner, or a tie is declared among two people, or a tie is declared among three people. How many different possible results are there in this contest? 2. A group of 9 people will be broken into 3 teams of 3. How many ways are there to do this? (Groups do not have IDs or order; they are defined by the subset of the teammates in the group). 6
Section 6 [14 pts (4,4,3,3)]: Probability You can leave your answers unsimplified in this section. 1. What is the probability of getting a different value on each die when rolling 6 6-sided dice? 2. What is the expected number of (aces + kings) in a hand of 7 random cards? (there are 4 aces and 4 kings in the deck of 52 cards) 3. What is the entropy of a symbol sequence with frequencies 1/4, 1/4, and 1/2? 7
Section 7 [15 pts (4,4,3,4)]: Algorithms, Recurrences, Growth of Functions 1. Given the beginning of a sequence a 1 = 1, a 2 = 3, a 3 = 9, a 4 = 19, a 5 = 33, a 6 = 51,..., find the general closed-form formula. 2. Is 3 n = O(2 n )? Argue why or why not, using the definition of big-o. 3. Between Selection Sort or Insertion Sort, which makes fewer comparisons on arrays that are almost sorted, save for a handful of items swapped with their neighbors? Explain your reasoning. 4. Which relations hold (ω, Ω, Θ, O, o) between the asymptotic growth rates of the following two recurrences: T (N) = 4T (N/4) + N and R(N) = 2R(N/2) + N? 8
Section 8 [16 pts (8, 8)]: Proofs 1. Prove that a n = 78n 2 6n is a multiple of 12, for any positive integer n. Hint: it can be done by factorizing the expression or by induction. 2. 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. 9