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

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

CS1800 Discrete Structures Final Version A

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

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

Discrete Mathematics GCD, LCM, RSA Algorithm

SAMPLE ANSWERS MARKER COPY

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:

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I

3 The fundamentals: Algorithms, the integers, and matrices

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

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

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

Counting in Different Number Systems

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

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

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()

4 Number Theory and Cryptography

Fundamentals of Digital Design

Conversions between Decimal and Binary

CSC 125 :: Final Exam December 14, 2011

CprE 281: Digital Logic

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

Problem # Number of points 1 /20 2 /20 3 /20 4 /20 5 /20 6 /20 7 /20 8 /20 Total /150

Lecture Notes. Advanced Discrete Structures COT S

Number Theory. Modular Arithmetic

Practice Midterm Exam Solutions

MATH3302 Cryptography Problem Set 2

MTH 310, Section 001 Abstract Algebra I and Number Theory. Sample Midterm 1

Number theory (Chapter 4)

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

Section 4. Quantitative Aptitude

ICS141: Discrete Mathematics for Computer Science I

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

UNIVERSITI TENAGA NASIONAL. College of Information Technology

1 Computing System 2. 2 Data Representation Number Systems 22

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

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

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal

CprE 281: Digital Logic

Number System conversions

Boolean Algebra & Logic Gates. By : Ali Mustafa

University of Regina Department of Mathematics and Statistics Math (Fall 2013) Final Exam December 10, 2013

Philadelphia University Student Name: Student Number:

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

Digital Logic (2) Boolean Algebra

Binary addition example worked out

Solutions to the Midterm Test (March 5, 2011)

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2.5 정수와알고리즘 (Integers 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:

Combinational Logic. By : Ali Mustafa

University of Florida EEL 3701 Fall 1996 Dr. Eric M. Schwartz

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

Cs302 Quiz for MID TERM Exam Solved

Base-b representations of integers. (b 진법표현 ) Algorithms for computer arithmetic: Euclidean algorithm for finding GCD s.

Digital Electronics Final Examination. Part A

CISC 1400 Discrete Structures

Philadelphia University Faculty of Engineering

7.2 Applications of Euler s and Fermat s Theorem.

Chapter 5. Number Theory. 5.1 Base b representations

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 2 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Lecture 2 Review on Digital Logic (Part 1)

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

Sample Marking Scheme

1 Boolean Algebra Simplification

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

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

CPE100: Digital Logic Design I

Modular Arithmetic Instructor: Marizza Bailey Name:

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

Lecture 4: Counting, Pigeonhole Principle, Permutations, Combinations Lecturer: Lale Özkahya

Four Important Number Systems

ENGIN 112 Intro to Electrical and Computer Engineering

Part IA Numbers and Sets

CHAPTER 3. Congruences. Congruence: definitions and properties

CHAPTER 12 CRYPTOGRAPHY OF A GRAY LEVEL IMAGE USING A MODIFIED HILL CIPHER

Fall 2017 September 20, Written Homework 02

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.

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

5 Group theory. 5.1 Binary operations

C-N Math 207 Discrete Math

C-N Math 207 Discrete Math

CPSC 467b: Cryptography and Computer Security

Hakim Weatherspoon CS 3410 Computer Science Cornell University

download instant at

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

W3203 Discrete Mathema1cs. Number Theory. Spring 2015 Instructor: Ilia Vovsha. hcp://

Modular Arithmetic and Elementary Algebra

The Euclidean Algorithm and Multiplicative Inverses

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

Questionnaire for CSET Mathematics subset 1

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

EEE130 Digital Electronics I Lecture #4

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

CPSC 467: Cryptography and Computer Security

Discrete Mathematics and Probability Theory Summer 2015 Chung-Wei Lin Midterm 1

For your quiz in recitation this week, refer to these exercise generators:

Transcription:

CS1800 Discrete Structures Fall 2017 October, 2017 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[14 points] Binary and Hexadecimal Section 2 [13 points] Logic Section 3 [15 points] Proof Section 4 [18 points] Modular Arithmetic & Algorithms Section 5 [10 points] Modular Cryptosystems Section 6 [10 points] Sets and Counting Section 7 [20 points] Permutations and Combinations Total Name: CS1800 (Lecture) Instructor: 1

Section 1 [14 pts: 4, 5, 5]: Binary, Octal, and Hexadecimal 1. Convert the binary number 100010101001 to decimal and hexadecimal. Solution: 2217 10, 8A9 16 2. Suppose that we prohibit leading zeroes in all number representations. In other words, 2017 would be a valid decimal number, but 02017 would not; 3AF would be a valid hexadecimal number, but 003AF would not; and so on. Now suppose that you are given a length 4 hexadecimal number where leading zeroes are prohibited, and you convert this number to binary. What is the minimum and maximum number of bits in the binary representation, again assuming that leading zeroes are prohibited? Explain. Solution: The least significant 3 hex digits correspond to 12 bits. The most significant hex digit can be 1 to 4 bits. Thus, the answer is 13-16 bits. 3. Convert the decimal number 46 to 8-bit 2 s complement. Convert the number 13 to 8-bit 2 s complement. Now perform the operation 46 13 in 8-bit 2 s complement. Verify that your result in 8-bit 2 s complement is correct, i.e., 33. Solution: 00101110, 11110011, 00100001, 32 + 1 = 33. 2

Section 2 [13 pts: 4, 4, 5]: Logic 1. Recall that a NAND b is (a b). Construct the truth table for (a NAND b) NAND c. Solution: Let F = (a NAND b) NAND c. a b c F 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 2. Give the Boolean formula for (a NAND b) NAND c using only the variables a, b, c and operators and. Now apply DeMorgan s Law as much as possible to simplify this expression. Solution: ( (a b) c) = (a b) c 3. Simplify the expression ((a b) ( a b)) a. Solution: This is actually simply (a XNOR b) a, and since XNOR requires its inputs to be the same to be satisfied, this is a b. One could also derive the simplification as: ((a b) ( a b)) a (a b) ( a b) a ( a b) (a b) a a (a b) a b 3

Section 3 [15 pts (8,7)]: Proofs 1. Prove that if a is relatively prime to n, then there is some b such that ((n a)(n b)) mod n = 1. Solution: Multiplying out, we get (n a)(n b) = n 2 an bn + ab, which mod n is equal to just ab. If a is relatively prime to n, we know it has a multiplicative inverse mod n. By the definition of a multiplicative inverse, this is a number b such that ab mod n = 1. Thus, the multiplicative inverse is the number desired. 2. Prove that ( )( n n q ( q t q) = n t t)( q), assuming n t q. Solution: Both sides count in how many ways can we choose a football team of q and a hockey team of t q from a set of n students. LHS: choose the football team first, then the hockey team from remaining students RHS: choose both teams as a set of size t q + q first, then choose the football team out of the selected set; the hockey team is what has been selected the first time but not the second time Algebra solution: ( )( ) n n q n! (n q)! = q t q q!(n q)! (n t)!(t q)! = n! q!(n t)!(t q)! = n! t! t!(t q)! q!(t q)! = ( n t )( t q ) 4

Section 4 [18 pts: 5,3,3,5,2]: Modular Arithmetic and GCD algorithms 1. Calculate 5 33 mod 7 via repeated squaring. Solution: 5 2 = 25 = 4 5 4 = 4 2 = 16 = 2 5 8 = 2 2 = 4 5 16 = 4 2 = 16 = 2 5 32 = 2 2 = 4 5 33 = 4 5 mod 7 = 20 mod 7 = 6 2. Perform the Euclidean algorithm (not extended) to find gcd(1233, 54). Solution: gcd(1233, 54) = gcd(54, 45) = gcd(45, 9). 9 divides 45, so the gcd is 9. 3. Using the result of the previous problem, what is lcm(1233,54)? (You can leave your answer unsimplified.) Solution: (1233*54)/9 = 1233*6 = 7398. 4. Perform the Extended Euclid algorithm to find x and y such that 19x + 17y = 1. Solution: a b x y d 19 17-8 9 1 17 2 1-8 1 2 1 0 1 1 1 0 1 0 1 5. Using the result of the previous problem, what is the multiplicative inverse of 17 mod 19? Solution: By the previous question s result, 9. 5

Section 5 [10 pts: 4,6]: Modular Cryptosystems 1. What is the smallest possible RSA public key value e 2 that works for n = 101 103 = 10403? Solution: The number needs to be relatively prime to φ(n) = 100 102 = 10200. 2 and 5 clearly don t work, so 4 also isn t relatively prime; a quick division shows 3 doesn t work either; but 7 doesn t go in evenly, so it s 7. 2. Consider valid linear ciphers of the form ax + b mod 35. (A cipher is valid if it is possible to create a unique decryption function. The null cipher a = 1, b = 0 is also considered valid here.) (a) How many different values are possible for b? (b) How many different values are possible for a? (c) How many different linear ciphers of this form are possible? Solution: (a) b can be anything in [0,34], so 35. (b) a must be relatively prime to n, so φ(35) = 4 6 = 24. (c) 24 35 = 840. 6

Section 6 [10 pts: 3,3,4]: Sets and Counting 1. Simplify ((A B) (C B)) A. Solution: 2. If A = 10, B = 6, and A B = 4, what is the size of P((A B) (A B))? Solution: 2 10+6 4 4 = 2 8 = 256 3. A deck of 52 cards contains cards with 13 possible values, 4 of each. How many cards must be drawn to guarantee a three-of-a-kind? Solution: 27, by the generalized pigeonhole principle. 7

Section 7 [20 pts: 3,5,8,4]: Permutations and Combinations For this section, you can leave your answers unsimplified. 1. How many top-5 rankings (1st through 5th place) are possible with 12 contestants? Solution: P(12,5) = 12*11*10*9*8 2. How many 5-digit pins are possible if exactly two digits are the same, with no other digits repeated? ( Solution: 5 ) 2 = 10 locations for the repeated digits, 10 possibilities for its identity, and the other digits are 9*8*7. 10 2 9 8 7 = 50400. 3. 20 students are told to split into four study groups: one of size 7, two of size 5, one of size 3. In how many different ways can they form the groups? (There s no ordering to the groups - arrangements are considered the same if everybody s teammates would be the same.) Solution: Choose the first group ( ( ) 20 7 ways) then the second group from remaining students ( ( ) ( 13 5 ways) and the third group ( 8 5) ways); the last group has no choice but the remaining 3. Apply product rule: ( ) ( 20 7 13 ) ( 5 8 ) 5 = 20! 7!5!5!3!. But every grouping has been counted twice, because the two groups of 5 are interchangeable without changing the answer. So the final answer is 1 20! 2 7!5!5!3!. 20! Solution variation: pics the groups of sizes 7,3,10 in 7!3!10!, Then compute the number of ways to split 10 into two subsets of 5 each (like weights partition problem ). That is 1 10 ) 2( 2 ways. 4. A book with 200 pages is to be organized into 8 chapters, but the editor does not like any chapter smaller than 10 pages. In how many ways can the pages be grouped into chapters to satisfy the editor constraint? Solution: This is balls in bins with the condition that the bin-counts have to be at least 10. So its not really 200 pages that are distributed since 8*10 of them are guaranteed as minimum 10 in each of the 8 chapters. The total ways to do this is to distribute 200-80 pages into 8 chapters; that is ( ) 120+8 1 8 1. To get the actual chapter sizes we take any resulted bin-count and add 10 to each bin. 8