Discrete Structures, Final Exam

Similar documents
Is g one-to-one? Is g onto? Why? Solution: g is not one-to-one, since for c A, g(b) = g(c) = c. g is not onto, since a / g(a).

Discrete Structures: Solutions to Sample Questions, Exam 2

Exam 2. Is g one-to-one? Is g onto? Why? Solution: g is not one-to-one, since for c A, g(b) = g(c) = c. g is not onto, since a / g(a).

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

Section Summary. Relations and Functions Properties of Relations. Combining Relations

Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

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

Tutorial Obtain the principal disjunctive normal form and principal conjunction form of the statement

CS1800 Discrete Structures Final Version A

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

Math 230 Final Exam, Spring 2008

Homework 7 Solutions, Math 55

Do not open this exam until you are told to begin. You will have 75 minutes for the exam.

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

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

Just the Factors, Ma am HAROLD B. REITER.

{a, b, c} {a, b} {a, c} {b, c} {a}

DISCRETE STRUCTURES AMIN WITNO

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

Sets and Motivation for Boolean algebra

Induction and Recursion

MATH 420 FINAL EXAM J. Beachy, 5/7/97

Problem Points Score Total 100

The least element is 0000, the greatest element is 1111.

Discrete Structures: Sample Questions, Exam 2, SOLUTIONS

Solutions to Practice Final

Exercises for Discrete Maths

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

1 What is the area model for multiplication?

1.A Sets, Relations, Graphs, and Functions 1.A.1 Set a collection of objects(element) Let A be a set and a be an elements in A, then we write a A.

Chapter 7: Exponents

Discrete Math I Exam II (2/9/12) Page 1

Mathathon Round 1 (2 points each)

Fall 2017 Test II review problems

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

Discrete Math, Fourteenth Problem Set (July 18)

Executive Assessment. Executive Assessment Math Review. Section 1.0, Arithmetic, includes the following topics:

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

Recursive Definitions

The Advantage Testing Foundation Solutions

Number Theory and Counting Method. Divisors -Least common divisor -Greatest common multiple

Prime Factorization and GCF. In my own words

1. Prove: A full m- ary tree with i internal vertices contains n = mi + 1 vertices.

CSC Discrete Math I, Spring Relations

MODERN APPLIED ALGEBRA

4. What is the probability that the two values differ by 4 or more in absolute value? There are only six

MATH 114 Fall 2004 Solutions to practice problems for Final Exam

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

Advanced Boolean Logic and Applications to Control Systems

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

Induction and recursion. Chapter 5

NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty.

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

CS 250/251 Discrete Structures I and II Section 005 Fall/Winter Professor York

(c) Give a proof of or a counterexample to the following statement: (3n 2)= n(3n 1) 2

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

COMPUTER SCIENCE TRIPOS

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007)

Relations Graphical View

Equivalence relations

Math Fall Final Exam. Friday, 14 December Show all work for full credit. The problems are worth 6 points each.

0 Sets and Induction. Sets

1. Induction on Strings

CMSC Discrete Mathematics FINAL EXAM Tuesday, December 5, 2017, 10:30-12:30

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY MA DISCRETE MATHEMATICS

Order of Operations. Real numbers

CSE 1400 Applied Discrete Mathematics Proofs

PRACTICE PROBLEMS: SET 1

MATH 363: Discrete Mathematics

NORTHERN INDIA ENGINEERING COLLEGE, LKO D E P A R T M E N T O F M A T H E M A T I C S. B.TECH IIIrd SEMESTER QUESTION BANK ACADEMIC SESSION

Discrete Mathematics. 2. Relations

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

CS6901: review of Theory of Computation and Algorithms

CSCE 551 Final Exam, April 28, 2016 Answer Key

COMP 182 Algorithmic Thinking. Relations. Luay Nakhleh Computer Science Rice University

3. Applying the definition, we have 2#0 = = 5 and 1#4 = = 0. Thus, (2#0)#(1#4) = 5#0 = ( 5) 0 ( 5) 3 = 2.

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

MC9211 Computer Organization

CMSC Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005

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

Evaluate algebraic expressions for given values of the variables.

Notes. Relations. Introduction. Notes. Relations. Notes. Definition. Example. Slides by Christopher M. Bourke Instructor: Berthe Y.

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December Points Possible

Math 4320 Prelim, Part I

Fundamentals of Mathematics (MATH 1510)

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

Algebra 1 Correlation of the ALEKS course Algebra 1 to the Washington Algebra 1 Standards

Exponents. Reteach. Write each expression in exponential form (0.4)

Name: Student ID: Instructions:

VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

Lecture Notes 1 Basic Probability. Elements of Probability. Conditional probability. Sequential Calculation of Probability

Multiple Choice Questions for Review

The Real Number System

West Windsor-Plainsboro Regional School District Algebra Grade 8

Name (please print) Mathematics Final Examination December 14, 2005 I. (4)

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December Points Possible

CS250, Fall 2010, Midterm 2, Tuesday November 9, 8am.

MockTime.com. (b) (c) (d)

Problem Points Score Total 100

Transcription:

Discrete Structures, Final Exam Monday, May 11, 2009 SOLUTIONS 1. (40 pts) Short answer. Put your answer in the box. No partial credit. [ ] 0 1 (a) If A = and B = 1 0 [ ] 0 0 1. 0 1 1 [ 0 1 1 0 0 1 ], compute A B. (b) The following digraph represents a tree. Which vertex is its root? C. (c) For the tree given below, list all the siblings of v 2. v 1, v 6. (d) Draw the Hasse diagram of the poset (P(S), ) for S = {x, y}. (e) Two fair dice are rolled. What is the probability that the sum of the two rolls is even? 1/2. One way to see this is to list out all the 36 possibilities and note that 18 of them have an even sum (so the probability is 18/36 = 1/2. Alternately, 1

you can reason as follows: If the two dice are rolled separately, then no matter what the first die says, there is a 1/2 probability of the second die making the sum even: if the first die is odd, then there is a 1/2 chance that the second die is odd also, making the sum even; on the other hand, if the first die is even, there is a 1/2 chance that the second die is even also, making the sum even again. So no matter what the first die gives, there is a 1/2 chance of having the second die make the sum even. (f) What is the number of nonisomorphic binary positional trees of height 2? 21. This takes a little work. First of all, consider the case of nonisomorphic binary positional trees of height 1: There are 3 = 2 2 1 cases here, represented by the pictures below. (Note the fourth case, where the root has neither a left nor a right node, is height 0, not height 1). Once we have analyzed the height-1 trees, we need to analyze how to add another level to make them height-2. For the two height-1 trees with just one offspring from the root, there are each 3 ways to do this (corresponding to tacking on the height-1 trees to the single leaf). The remaining height-1 tree is different: it has 2 leaves, and so there are 4 places to put level-2 offspring (each leaf has a left and right place). This means there are 2 4 = 16 ways to put in these offspring, but we must rule out the single case of no level-2 offspring to leave us with 15. So in total there are 2(3) + 15 = 21 possible nonisomorphic binary positional trees of height 2. (g) Compute the combination 6 C 4. Your answer should be in the form of an integer. 6 C 4 = 6! = 720 = 15. 4!2! 24 2 (h) Let T be a tree with root v 0. If w is a vertex of the tree different from v 0, what is the in-degree of T at w? 1. 2

(i) What is the Θ class of n(n lg n+ 3 n+1500)? Your choices are Θ(n lg n), Θ(n), Θ(n 5 6), Θ(n 1 2), Θ(n 3 2 lg n) and Θ(1). Θ( n(n lg n + 3 n + 1500)) = Θ(n 3 2 lg n + n 5 6 + 1500n 1 2) = Θ(n 3 2 lg n). (The last equality is because the second and third terms have lower Θ class than the first: Note Θ(n 3 2 lg n) > Θ(n 3 2) since Θ(lg n) > Θ(1). Moreover, Θ(n 3 2) > Θ(n 5 6) > Θ(n 1 2) = Θ(1500n 1 2) by comparing the exponents of the powers of n.) (j) Given the digraph of the Moore machine below, what is f 10 (s 0 )? s 1. (k) List all the acceptance states of the Moore machine above. s 2, s 3. (l) What is the number of ways the letters of the word carp can be permuted? Express your answer as an integer. 24. The word carp has 4 distinct letters, and so the number of permutations is 4! = 24. (m) If a 0 = 3, a 1 = 2, and a n is defined recursively by a n = 2a n 2 + a n 1 for n 2, what is a 3? a 3 = 2a 1 + a 2 = 2(2) + (2a 0 + a 1 ) = 4 + [2(3) + 2] = 12. (n) If M = 1 0 1 0 0 1 0 1 0 of R in the box. is the matrix of a relation R on {1, 2, 3}, draw the digraph (o) What is the matrix of the symmetric closure of the relation R from part (n)? 1 0 1 0 0 1. This is the same as M M. 1 1 0 (p) What is the matrix of the transitive closure of the relation R from part (n)? 1 1 1 0 1 1. You can compute this using Warshall s algorithm, or 0 1 1 the formula M M 2 M3, or by simply looking at the digraph to see that there 3

are paths from 1 to 2 (1 3 2), from 2 to 2 (2 3 2), and from 3 to 3 (3 2 3). (q) What is the number of four-letter passwords, consisting of all lowercase letters, that can be formed? (You do not have to simplify your answer.) 26 4. This is because repetition is allowed and order matters. So for each letter of the password, there are exactly 26 choices. (r) Draw the Hasse diagram of a poset which is not a lattice. This poset is not a lattice since a, b have no LUB. (s) Write the decimal number 13 in binary (base two). 13 = (1101) 2. (t) If f 0 and f 1 are functions in a finite-state machine with inputs {0, 1}, then the composition f 0 f 1 is equal to (your answer should be one of: f 0, f 1, f 01, f 10 ). f 10. 2. (a) (4 pts) Write the labeled positional binary tree corresponding to the fully parenthesized expression (((x + 2)/((3 4) (y y))) + 5) (b) (4 pts) Write the result of a POSTORDER search on the tree in part (a) above. x 2 + 3 4 y y / 5 + 3. (5 pts) Given the standard ordering on digits 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9, write the following strings of digits in lexicographic order. (This is not necessarily the same as numerical order.) 107 1073 5233 905 93 1073 107 93 5233 905 4

4. (a) (3 pts) Fill in the blanks in the following table n (2n) mod 5 (2n + 1) mod 5 0 0 1 1 2 3 2 4 0 3 1 2 4 3 4 (b) (7 pts) Draw the digraph of a Moore machine which accepts only those positive binary integers (strings of 0 s and 1 s) which are divisible by 5. The input set should be {0, 1}, and you will need five states s 0, s 1, s 2, s 3, s 4. The state s i should be represent binary integers which are equal to i mod 5. (Hint: If n is an integer written in binary, then the concatenation n 0 represents 2n in binary, while n 1 represents 2n + 1 in binary. Relate this to the table above.) 5. (12 pts) Consider the Moore machine with acceptance state T = {s 2 } and state transition table 0 1 s 0 s 1 s 1 s 1 s 1 s 2 s 2 s 2 s 2 (a) Draw the digraph of this Moore machine. 5

(b) Describe in words the language of the Moore machine above. All strings of bits which contain at least one 1 which is not the first bit. (c) Give a regular expression on {0, 1} whose regular set is the language of the Moore machine above. (0 1)0 1(0 1). (d) Write, in BNF, a phase structure grammar which gives the same language as the Moore machine above. s 0 ::= 0 s 1 1 s1 s 1 ::= 0 s 1 1 s2 s 2 ::= 0 s 2 1 s2 Λ 6. (8 pts) Consider the Boolean function f = f(x, y, z, w) given by this table x y z w f 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 (a) In the space below, draw the Karnaugh map for f. (b) Use the Karnaugh map from part (a) above to find a Boolean expression for f. Your expression should be as simple as possible. Justify your answer. (x y z ) (y w ). 7. (4 pts) Consider the relation R on A = {a, b, c, d, e} whose matrix is 1 0 0 0 1 0 1 1 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 1 Is R an equivalence relation on A? If so, write down the partition of A corresponding to R. If not, explain why not. 6.

R is an equivalence relation corresponding to the partition {{a, e}, {b, c}, {d}} of A. 8. (6 pts) Let A = { 1, 0, 1}, a subset of the integers, and consider the mathematical structure (A, +, ), where + and are addition and multiplication. (a) Is A closed under? Why or why not? A is closed under since the product of each two elements of A is again an element of A. (b) Is A closed under +? Why or why not? A is not closed under + since e.g. 1 + 1 = 2 / A. 9. (8 pts) Consider S = {1, 2, 3, 6, 12} with the partial order of divisibility. (a) Draw the Hasse diagram of the poset S. (b) Is the poset S a lattice? Why or why not? S is a lattice, since the GLB and LUB always exist for each pair of elements of S. 10. (40 pts) True/False. Circle T or F. No explanation needed. For questions (a)-(e) below, consider the following master syntax diagram for a phase structure grammar G. 7

(a) T F abc L(G). F. Each string in the language must end in d. (b) T F abbcabbbcd L(G). F. You can never produce just two b s in a row (only an odd number). (c) T F ab(bb) c(ab(bb) c) d is a regular expression whose regular set is equal to L(G). T. (d) T F L(G) is a finite set of strings on {a, b, c, d}. F. L(G) is an infinite set, since for example any ab 2n+1 cd L(G) for n = 0, 1, 2, 3,.... (e) T F L(G) is a Type 3 language. T. It corresponds to a regular set, which implies it must be a Type 3 language. (f) T F If H = (V, S, v 0, ) is a phase structure grammar given by V = {v 0, x, y}, S = {x, y}, given by v 0 xv 0 x, v 0 y, then L(H) = {x n yx n n = 0, 1, 2,... }. T. The production must end in y, and identical numbers of x s are supplied on either side of y by repetitions of v 0 xv 0 x. (g) T F For H the grammar from part (f), the language L(H) is a Type 3 language. F. Any Type 3 language corresponds to a Moore machine, which has a finite number of states. Since the number of x s on either side of the y is the same for each string in the language, then the Moore machine would have to count the number of x s before the y and then produce the same number of x s afterward. Each different number of x s would require its own state (one state for each n = 0, 1, 2, 3,...) This cannot be accomplished by a finite-state machine. (h) T F If p, q are Boolean variables which are both true, what is (p q) q? F. (T T) T = (F T) T = T T = F T = F. (i) T F If h is the mod 11 function, then h(80) = 8. F. h(80) = 80 mod 11 = 3 8. (j) T F n! has lower Θ class than 10 n. F. As we discussed in class, n! has higher Θ class than any exponential function of n, since n! lim n =. 10 n 8

(k) T F The expression 6 3 + 3 2, in postfix notation, evaluates to be a prime number. T. Evaluate in postfix: 6 3 + 3 2 = 9 3 2 = 9 6 = 3, which is prime. (l) T F A tree, when considered as a relation on the set of its vertices, is always transitive. F. In a tree T, atb btc at/ c. (m) T F If B is a finite Boolean algebra represented by the three Boolean variables x, y, z, then the minterm of 001 is x y z. T. (n) T F Every linearly ordered set is a lattice. T. In a linearly ordered set, it is easy to show that GLB(a, b) = min(a, b) and LUB(a, b) = max(a, b). (o) T F If A is a subset of a universal set U, then Ā A =. T. (p) T F The greatest common divisor of 48 and 92 is 2. F. The GCD of 48 and 92 is 4. (q) T F Every finite poset has at least one minimal element. T. (r) T F Consider the phase structure grammar K with starting state v 0 and BNF given by v 0 ::= 01 0 w w ::= 11 w 1 v0 Then 011101 L(K). T. v 0 0w 011w 0111v 0 011101. (s) T F For K the grammar in part (r), 0w 011w. T. (t) T F For K the grammar in part (r), the language L(K) is the regular set of the regular expression 0(10 1110) 1. F. This regular expression excludes e.g. 01111101, which is in the language. A correct regular expression is 0(1(11) 0) 1. 9