CS1800 Discrete Structures Final Version A

Similar documents
CS1800 Discrete Structures Fall 2016 Profs. Gold & Schnyder April 25, CS1800 Discrete Structures Final

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague 27 October, CS1800 Discrete Structures Midterm Version A

CS1800 Discrete Structures Fall 2017 October, CS1800 Discrete Structures Midterm Version A

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A

Number Theory: Representations of Integers

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

Cs302 Quiz for MID TERM Exam Solved

Combinational Logic. By : Ali Mustafa

UNIVERSITI TENAGA NASIONAL. College of Information Technology

CSC 125 :: Final Exam December 14, 2011

S C F F F T T F T T S C B F F F F F T F T F F T T T F F T F T T T F T T T

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

REVIEW QUESTIONS. Chapter 1: Foundations: Sets, Logic, and Algorithms

Midterm 1. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You:

Discrete Structures, Final Exam

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

Schedule. ECEN 301 Discussion #25 Final Review 1. Date Day Class No. 1 Dec Mon 25 Final Review. Title Chapters HW Due date. Lab Due date.

Fall 2017 November 10, Written Homework 5

Midterm 2. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You:

Quiz 2 Room 10 Evans Hall, 2:10pm Tuesday April 2 (Open Katz only, Calculators OK, 1hr 20mins)

Midterm Examination # 1 Wednesday, February 25, Duration of examination: 75 minutes

1 Sequences and Summation

Fundamentals of Digital Design

UNIVERSITY OF VICTORIA DECEMBER EXAMINATIONS MATH 122: Logic and Foundations

MATH 114 Fall 2004 Solutions to practice problems for Final Exam

UC Berkeley, CS 174: Combinatorics and Discrete Probability (Fall 2008) Midterm 1. October 7, 2008

CSE 20 DISCRETE MATH. Fall

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Exam in Discrete Mathematics

Strong Mathematical Induction

Exam for Physics 4051, October 31, 2008

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

Digital Electronics Final Examination. Part A

Chapter 2. Digital Logic Basics

Trinity Christian School Curriculum Guide

CprE 281: Digital Logic

CMSC Discrete Mathematics SOLUTIONS TO FIRST MIDTERM EXAM October 18, 2005 posted Nov 2, 2005

Computer Science Foundation Exam

Fall 2017 September 20, Written Homework 02

DISCRETE STRUCTURES AMIN WITNO

Fall 2017 Test II review problems

Philadelphia University Student Name: Student Number:

Propositional Logic. What is discrete math? Tautology, equivalence, and inference. Applications

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

Math Circle: Recursion and Induction

AMTH140 Trimester Question 1. [8 marks] Answer

Logic Gates - Introduction

Solutions to the Mathematics Masters Examination

CSC 125 :: Final Exam May 3 & 5, 2010

Definition 6.1 (p.277) A positive integer n is prime when n > 1 and the only positive divisors are 1 and n. Alternatively

Notation Index. gcd(a, b) (greatest common divisor) NT-16

1. Basics of Information

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

SAMPLE EXAMINATION PAPER

McGill University Faculty of Science. Solutions to Practice Final Examination Math 240 Discrete Structures 1. Time: 3 hours Marked out of 60

LOGIC GATES. Basic Experiment and Design of Electronics. Ho Kyung Kim, Ph.D.

PRIMES Math Problem Set

Binary addition example worked out

Additional Gates COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Discrete Mathematics GCD, LCM, RSA Algorithm

Philadelphia University Student Name: Student Number:

EECS150 - Digital Design Lecture 21 - Design Blocks

MATH3302 Cryptography Problem Set 2

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

ELCT201: DIGITAL LOGIC DESIGN

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

Discrete Mathematics. Spring 2017

Solutions to Tutorial 4 (Week 5)

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

DIGITAL CIRCUIT LOGIC BOOLEAN ALGEBRA

Number theory (Chapter 4)

Name: Exam 2 Solutions. March 13, 2017

3. A square has 4 sides, so S = 4. A pentagon has 5 vertices, so P = 5. Hence, S + P = 9. = = 5 3.

CS1800: Mathematical Induction. Professor Kevin Gold

Packet #1: Logic & Proofs. Applied Discrete Mathematics

CS483 Design and Analysis of Algorithms

BOOLEAN ALGEBRA INTRODUCTION SUBSETS

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit

CS1800: Hex & Logic. Professor Kevin Gold

ENGIN 112 Intro to Electrical and Computer Engineering

Outline. policies for the first part. with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion

Induction and Recursion

Carry Look Ahead Adders

Menu. Review of Number Systems EEL3701 EEL3701. Math. Review of number systems >Binary math >Signed number systems

Simplification by Truth Table and without Truth Table

Systems I: Computer Organization and Architecture

NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt):

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

MC9211 Computer Organization

Quiz 2 Solutions Room 10 Evans Hall, 2:10pm Tuesday April 2 (Open Katz only, Calculators OK, 1hr 20mins)

Chapter 2. Boolean Algebra and Logic Gates

Chapter 8 Sequences, Series, and Probability

Digital Logic (2) Boolean Algebra

ICS141: Discrete Mathematics for Computer Science I

UNIVERSITY OF MICHIGAN UNDERGRADUATE MATH COMPETITION 27 MARCH 28, 2010

University of Florida EEL 3701 Fall 2014 Dr. Eric. M. Schwartz Department of Electrical & Computer Engineering Wednesday, 15 October 2014

Transcription:

CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 11, 2017 CS1800 Discrete Structures Final 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 [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 (3,4,4) ]: Binary and Other Bases 1. Convert the number -17 to 8-bit two s complement. Sol: 11101111 2. What is the result, in hexadecimal, of multiplying the hexadecimal number 0xABCD by the decimal number 256? Hint: You do not need to convert these numbers to a common base or actually perform the multiplication. Sol: 0xABCD00 3. Suppose that a given hexadecimal number has d total hex digits, of which exactly k are non-zero hex digits. What are the minimum and maximum number of 1s in the binary representation of this number and why? Sol: The minimum is k and the maximum is 4k, since a nonzero hex digit must have at least one bit in its binary representation and may have as many as all 4 (F). 2

Section 2 [12 pts (2,3,3,4)]: Logic and Circuits A k-input parity gate is a logic gate whose output is 1 if and only if an odd number of its inputs is 1. 1. A 2-input parity gate is equivalent to what logic gate that we discussed in the course? Sol: XOR 2. Give the truth table for a 3-input parity gate. Sol: True rows are 001, 010, 100, 111. 3. Give a Boolean formula in DNF form for a 3-input parity gate. Sol: ( a 1 a 2 a 3 ) ( a 1 a 2 a 3 ) (a 1 a 2 a 3 ) (a 1 a 2 a 3 ) 4. Consider the 4-input circuit shown below. What function of the inputs a 1, a 2, a 3, a 4 does this circuit compute and why? a1 a2 2-input parity 2-input parity out a3 a4 2-input parity Sol: It computes a 4-input parity circuit. Exactly one of the two input gates needs to have odd parity for all the bits to have odd parity, since two inputs with odd parity or two inputs with even parity would both have even parity. 3

Section 3 [12 pts (4, 2, 3, 3)]: Modular Arithmetic and Algorithms 1. Calculate 7 10 mod 11 using repeated squaring. Sol: 7 2 mod 11 = 5, 7 4 mod 11 = 5 2 mod 11 = 3, 7 8 mod 11 = 3 2 mod 11 = 9, 7 10 = 7 8 7 2 mod 11 = 9 5 mod 11 = 1 2. The following are candidate RSA public/private key pairs. For each such pair, determine whether the pairs are valid RSA keys. If they are valid, state why; if they are not valid, state why not. (a) Public: (e, n) = (7, 32). Private: (d, n) = (5, 32) Sol: Invalid: 32 is not the product of two primes. (b) Public: (e, n) = (7, 33). Private: (d, n) = (4, 33). Sol: Invalid: 4 is not the multiplicative inverse of 7 (mod 20), since 4 7 = 28 = 8 (mod 20). Or: 4 is not relatively prime to 20. (c) Public: (e, n) = (7, 33). Private: (d, n) = (3, 33). Sol: Valid: 33 is the product of two primes, 3 and 11. (3 1) (11 1) = 2 10 = 20. 7 is relatively prime to 20. 3 is the multiplicative inverse of 7 (mod 20), since 3 7 = 21 = 1 (mod 20). 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) C. Sol: {a, b, c} 2. How many elements are in P(A B)? Sol: 2 3 3 = 512 3. If D = {x x Z, x 2 9}, what is D? Sol: 7 ({ 3, 2, 1, 0, 1, 2, 3}) 5

Section 5 10 pts (5,5): Counting For these problems, we expect your answers to be simplified into integers for full credit. 1. How many different undirected graphs are possible with the same set of 5 vertices V = {A, B, C, D, E}, but different sets of edges E? Sol: C(5,2) = 5*4/2 = 10 possible edges that could either be there or not, so 2 1 0 = 1024 possible graphs. 2. A group of 9 people will be broken into 3 teams of 3, with each team assigned a letter A, B, or C. How many ways are there to do this? Sol: C(9,3)*C(6,3) = (9*8*7/3*2)(6*5*4/3*2) = 1680. 6

Section 6 [14 pts (3,5,6)]: Probability Give your probabilities and expectations as simplified fractions or integers. 1. When rolling four six-sided dice, what is the probability of rolling the same number on all six dice? Sol: 6 possible values among 6 4 results = 1/6 3 = 1/216. 2. A set of tiles A,B,C,D,E,F is randomly shuffled. What is the probability that the tiles A,B,C are adjacent and in order in the resulting ordering? Sol: 4 places for ABC: A B C - - -, - A B C - -, - - A B C -, - - - A B C (0-3 leading tiles). The remaining slots have 3! possibilities. So the numerator of this probability is 4*6. The denominator is the number of ways to permute all the tiles, 6!. So the probability is 4 6/6 5 4 3 2 = 1/5 3 2 = 1/30. 3. A graph has 10 vertices, and we are independently putting each possible edge in E with probability 0.5. What is the expected number of cycles of length 3? Sol: For any particular cycle, (1/2) 3 = 1/8 probability that all three edges are present. There are C(10,3) = 120 possible cycles. So the expected number of cycles is 1/8 * 120 = 15. 7

Section 7 [15 pts (4,4,3,4)]: Algorithms, Recurrences, Growth of Functions 1. Given the beginning of a sequence a 1 = 2; a 2 = 9; a 3 = 22; a 4 = 41; a 5 = 66; a 6 = 97, find the general closed-form formula. Sol: 3n 2 2n + 1 2. Is the choice of constants c = 2, n 0 = 100 sufficient to prove 100n = O(n) by the definition of big-o, assuming these constants mean what they usually do? Explain why or why not. Sol: No, because 100(100) 2(100) is not true, so the definition of big-o isn t satisfied at n 0. 3. An algorithm for arrays works as follows: - it analyses each element of the input array (one pass) - then recurses (calls itself) on a chunk of at most three quarters of the array (a) Write the recursion for the running time. Sol: T (N) = T (3N/4) + N (b) Given that the work done by the algorithm is N +(3/4)N +(3/4) 2 N +... use an infinite geometric series to estimate the total number of operations as a function of N. Sol: N 1/(1 3/4) = 4N 8

Section 8 [16 pts (7, 3, 6)]: Proofs 1. Prove that every undirected graph has an even number of vertices of odd degree. Sol: By the handshaking lemma, the sum of all the degrees of the graph is even. So the total degree sum must equal 0 mod 2. Each even degree vertex contributes 0 mod 2 to this sum, and each odd degree vertex contributes 1 mod 2 to this sum. An odd number of odd vertices would create a sum of 1 mod 2, which is impossible. So the number of odd degree vertices must be even. 9

2. A sequence is given by base a 0 = 0 and recurrence a n+1 = a n + 1 + ( 1) n for n 0 (a) Prove that a n+2 = a n + 2 ( 1) n+1 for n 0. Sol: Just by substituting twice in the original formula, we have a n+2 = ( a n + 1 + ( 1) n ) + 1 + ( 1) n = a n 1 ( 1) n + 1 + ( 1) n+1 = a n ( 1) n + ( 1) n+1 = a n + ( 1) n+1 + ( 1) n+1 = a n + 2 ( 1) n+1 (b) Prove by induction that all values in the sequence are even. Sol: Base cases: a 0 = 0 is even. a 1 = 0 + 1 + ( 1) 0 = 2 is even. Inductive hypothesis: Suppose all a n are even for n k. Inductive step: By what was proven in the earlier part, a k+1 = a k 1 + 2 ( 1) n+1. By the inductive hypothesis, a k 1 is even. 2 ( 1) n+1 has a factor of 2, and therefore is also even, so the whole right side is even for a k+1, and therefore, a k+1 is even. 10