CPSC 121 Sample Final Examination December 2013

Similar documents
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

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

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

Sample Problems for all sections of CMSC250, Midterm 1 Fall 2014

Logic, Sets, and Proofs

Packet #1: Logic & Proofs. Applied Discrete Mathematics

What is the decimal (base 10) representation of the binary number ? Show your work and place your final answer in the box.

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics. Introductory Notes in Discrete Mathematics Solution Guide

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

5. Use a truth table to determine whether the two statements are equivalent. Let t be a tautology and c be a contradiction.

Today s Topics. Methods of proof Relationships to logical equivalences. Important definitions Relationships to sets, relations Special functions

MATH 13 SAMPLE FINAL EXAM SOLUTIONS

CPSC 121 Midterm 1 Friday February 5th, 2016

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

Solutions to Sample Problems for Midterm

Discrete Structures CRN Test 3 Version 1 CMSC 2123 Autumn 2013

CS280, Spring 2004: Prelim Solutions

CSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4

ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS

COM S 330 Homework 05 Solutions. Type your answers to the following questions and submit a PDF file to Blackboard. One page per problem.

Propositional Logic. Logical Expressions. Logic Minimization. CNF and DNF. Algebraic Laws for Logical Expressions CSC 173

COMPUTER SCIENCE TRIPOS

Problem 1: Suppose A, B, C and D are finite sets such that A B = C D and C = D. Prove or disprove: A = B.

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

a + b = b + a and a b = b a. (a + b) + c = a + (b + c) and (a b) c = a (b c). a (b + c) = a b + a c and (a + b) c = a c + b c.

COMPUTER SCIENCE TRIPOS

Properties of the Integers

Math 3336: Discrete Mathematics Practice Problems for Exam I

Recitation 7: Existence Proofs and Mathematical Induction

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

CPSC 121: Models of Computation. Module 9: Proof Techniques (part 2) Mathematical Induction

CPSC 121 Midterm 1 Tuesday, October 11th, 2011

CSC 125 :: Final Exam December 14, 2011

WUCT121. Discrete Mathematics. Logic. Tutorial Exercises

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

CSE 20 DISCRETE MATH WINTER

CSE 20 DISCRETE MATH SPRING

Proofs. Chapter 2 P P Q Q

Math 13, Spring 2013, Lecture B: Midterm

Discrete Mathematical Structures: Theory and Applications

Automata Theory and Formal Grammars: Lecture 1

HANDOUT AND SET THEORY. Ariyadi Wijaya

10/12/2016. An FSM with No Inputs Moves from State to State. ECE 120: Introduction to Computing. Eventually, the States Form a Loop

Definition 2. Conjunction of p and q

Wollongong College Australia

CSE 1400 Applied Discrete Mathematics Proofs

CS103 Handout 12 Winter February 4, 2013 Practice Midterm Exam

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

Math 230 Final Exam, Spring 2009

CPSC 121 Sample Midterm Examination October 2007

Proofs. Chapter 2 P P Q Q

CSCE 222 Discrete Structures for Computing. Review for Exam 1. Dr. Hyunyoung Lee !!!

Proof Techniques (Review of Math 271)

MATH FINAL EXAM REVIEW HINTS

18.S097 Introduction to Proofs IAP 2015 Lecture Notes 1 (1/5/2015)

Propositional Logic. Fall () Propositional Logic Fall / 30

Boolean Algebra and Proof. Notes. Proving Propositions. Propositional Equivalences. Notes. Notes. Notes. Notes. March 5, 2012

Module 9: Mathematical Induction

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Solutions to 2015 Entrance Examination for BSc Programmes at CMI. Part A Solutions

MAS114: Solutions to Exercises

CMSC 250 Spring 2016: Final Exam Review Questions Key

Predicate Logic. Andreas Klappenecker

Definition: Let S and T be sets. A binary relation on SxT is any subset of SxT. A binary relation on S is any subset of SxS.

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

EECS150 - Digital Design Lecture 23 - FSMs & Counters

CSE 20 DISCRETE MATH. Winter

Quiz 1. Directions: Show all of your work and justify all of your answers.

1.1 Statements and Compound Statements

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.

Analysis of Clocked Sequential Circuits

Lecture 10: Synchronous Sequential Circuits Design

Logic for Computer Science - Week 5 Natural Deduction

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

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination I (Spring 2008)

Topics in Logic and Proofs

Introduction to Automata

CSE 20 DISCRETE MATH. Fall

Propositional Logic. Spring Propositional Logic Spring / 32

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

THE LOGIC OF COMPOUND STATEMENTS

Propositional Logic, Predicates, and Equivalence

Lecture 7 Feb 4, 14. Sections 1.7 and 1.8 Some problems from Sec 1.8

8. Given a rational number r, prove that there exist coprime integers p and q, with q 0, so that r = p q. . For all n N, f n = an b n 2

Introduction to Metalogic

AN INTRODUCTION TO MATHEMATICAL PROOFS NOTES FOR MATH Jimmy T. Arnold

The Design Procedure. Output Equation Determination - Derive output equations from the state table

EE 109 Final Don t Make the Same Mistake

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

CSE 20. Final Review. CSE 20: Final Review

Selected problems from past exams

Chapter 5 Synchronous Sequential Logic

CPSC 121: Models of Computation

Homework 3: Solutions

Basic counting techniques. Periklis A. Papakonstantinou Rutgers Business School

CS1800: Mathematical Induction. Professor Kevin Gold

Homework #4. CSE 140 Summer Session Instructor: Mohsen Imani. Only a subset of questions will be graded

Notes on induction proofs and recursive definitions

Transcription:

CPSC 121 Sample Final Examination December 201 [6] 1. Short answers [] a. What is wrong with the following circuit? You can not connect the outputs of two or more gates together directly; what will happen if one of the gates tries to drive it high while the others try to drive it low? [] b. Explain briefly the difference between the purpose of a half-adder and that of a fulladder. A half-adder computes the sum of two bits. A full-adder adds three bits (two bits and a carry from a previous position). [6] 2. Let A = {1, 2,..., 299, 00}. [] a. Give an example of a function f from Z + into A that is not onto (surjective). The function f defined by f(x) = 1 is not onto (there is no positive integer x such that f(x) = 2). [] b. Consider the function f : {1, 2,..., 18} A defined by f(x) = x 2 x +. Is f one-to-one (injective)? Explain why or why not. No, because f(1) = f(2) = 1. [9]. Number representation [] (a) What unsigned integer is represented by the 9-bit value 100111011? 256 + 2 + 16 + 8 + 2 + 1 = 15 [] (b) What signed integer is represented by the 9-bit value 100111011? 256 + 2 + 16 + 8 + 2 + 1 = 197 [] (c) A professional programmer wrote a program that takes a floating point number x, sets its value to 0, and then adds 0.1 to x repeatedly until it becomes equal to 10, printing each value of x as it goes. Why does the program produce the output 0.0 0.1 0.2 0. 0.4 0.5 0.6 0.70000005 0.8000001 0.9000001 1.0000001 1.1000001 1.2000002

page 2 (and so on) instead of? 0.0 0.1 0.2 0. 0.4 0.5 0.6 0.7 0.8 0.9 1.0 The value 0.1 can not be represented exactly as a (binary) floating point value. Hence the value being added is not actually 0.1, but a number that s just a little bit larger than 0.1. This also means that the sum will never be exactly equal to 10 (and so the program will keep going, and going, and going, and... ) [12] 4. Consider the following circuit: The terminal and the onebit subcircuit provide bits one at a time to the remainder of the circuit, and the clock attached to the D flip-flops ticks each time a bit is available. [4] a. Suppose that the user first flips the reset switch on, then off, and finally types in the digits 0, 0, 1, 1, 0, 1, 1, 0 in this order. What will be the state of the LED (on/off) after each of the digits is typed (you need to provide 8 answers). The LED will be off, off, on, off, on, on, off and on respectively. [4] b. Explain in English the purpose of this circuit. The ouput is true (on) if the last two bits entered were different, and false (off) if they were the same. [4] c. Show how to modify the part of the circuit that is inside the gray box so the LED would be on if an odd number of 1 digits had been typed, and off if an even number of 1 digits had been typed. Hint: you will only need one flip-flop, and a few other gates.

page [7] 5. Determine the validity of the following argument. Justify your answer fully. 1. ( p q) r 2. r (s t). s u 4. u t p 5. u specialization from () 6. t modus ponens from () and (5) 7. s specialization from () 8. s t conjunction from (6) and (7) 9. (s t) DeMorgan s law from (8) 10. r modus tollens from (2) and (9) 11. ( p q) modus tollens from (1) and (10) 12. p q demorgan s law from (11) 1. p specialization from (12) 14. p double negative law from (1) Therefore the argument is valid. [9] 6. A perfect number is a positive integer that is equal to the sum of its divisors (except itself). For instance, 28 is perfect since 28 = 1 + 2 + 4 + 7 + 14. In this question, we will look at almost-perfect numbers: numbers that are one more than the sum of their divisors (except themselves). For instance, 16 is almost perfect since 1+2+4+8 = 15. Consider the following statement: Given any positive integer n, we can always find an almost-perfect number that is larger than n. [] a. Translate this statement into first-order logic (that is, using predicates and quantifiers). You may assume the existence of a predicate isalmostperfect. n Z +, x Z +, x > n isalmostperfect(x) [6] b. Prove the statement. Hint: look carefully at the example I gave, and see if you can make it more general. Consider an unspecified positive integer n. There is a power of 2 (say x = 2 n ) that is larger than n. The divisors of x are 2 0, 2 1,..., 2 n 1, 2 n. Hence the sum of the divisors (other than x) is n 1 2 i = 2 n 1 i=0 which means that x is almost perfect. [11] 7. Let U = {1, 2,, 4, 5, 6, 7, 8, 9, 10, 11, 12}, and f be a function from U into U. Finally, let F : P(U) P(U) be the function defined by F (X) = {f(x) x X}

page 4 For instance, if f(x) = 1 x, and X = {1,, 4, 7}, then F (X) = {f(1), f(), f(4), f(7)} = {12, 10, 9, 6}. [7] a. Prove that for every two subsets A, B of U, we have F (A B) F (A) F (B). Consider two unspecified subsets A, B of U, and choose an arbitrary element x of F (A B). We need to prove that x F (A) F (B). Since x F (A B), there exists an element y of A B such that x = f(y). Because y A B, we know that y A and hence x = f(y) F (A). Similarly y B and so x = f(y) F (B). This implies that x F (A) F (B). [4] b. Give an example that shows that F (A B) is not necessarily a subset of F (A) F (B). Let A = {1, 2}, B = {1} and f(x) = 1 for every x U. Then F (A B) = F ({2}) = {1}, but F (A) F (B) = {1} {1} =. [8] 8. Prove that for every positive integer n, n i(i + 1) = We prove the theorem by induction on n. When n = 1, and n i(i + 1) = 1 2 = 2 = 1 2 = 2. Hence the theorem holds for the base case n = 1. Now let us prove the induction step. Consider an unspecified positive integer n 1. Suppose that the theorem holds for n, that is suppose that n i(i + 1) =. We need to prove that the theorem holds for n + 1. Indeed ( n+1 n ) i(i + 1) = i(i + 1) + (n + 1)(n + 2) = + (n + 1)(n + 2) by the induction hypothesis ( n ) = (n + 1)(n + 2) + 1 = (n + 1)(n + 2) n + (n + 1)(n + 2)(n + ) =

page 5 [8] 9. The inhabitants of the country of Pirlouitland use only three kinds of coins, worth 1 schlip, 5 schlips and 10 schlips respectively. Johan, one of the knights, makes the following observation: For every amount n 10 schlips, the way to pay for n schlips that uses the fewest coins always contains a 10 schlip coin. Prove Johan s observation using an indirect proof. Hint: think of substituting some coin(s) for other coin(s). We start by assuming that the conclusion is false, that is, that there exists an amount n 10 schlips for which the way to pay this amount with the fewest coin does not use a 10 schlip coin. There are three cases to consider: If the smallest collection of coins that adds up to n schlips contains two or more 5 schlip coins, then we can replace two of the 5 schlip coins by a single 10 schlip coin. This gives us a way to pay for n schlips using fewer coins than the solution that uses the fewest coins (a contradiction). If the smallest collection of coins that adds up to n schlips contains exactly one 5 schlip coins, then it must also contain at least five 1 schlip coins. We can replace the 5 schlip coin and five of the 1 schlip coins by a single 10 schlip coin. This gives us a way to pay for n schlips using fewer coins than the solution that uses the fewest coins (a contradiction). If the smallest collection of coins that adds up to n schlips does not contain any 5 schlip coin, then it must also contain at least ten 1 schlip coins. We can replace ten of the 1 schlip coins by a single 10 schlip coin. This gives us a way to pay for n schlips using fewer coins than the solution that uses the fewest coins (a contradiction). We found a contradiction no matter how our solution without 10 schlip coins was constructed, which means our assumption that such a solution exists was wrong. [12] 10. Mathematical Induction [] a. Explain briefly the two forms of mathematical induction discussed in class. In one form, we have a single base case, and for the induction step we assume that the theorem is true for an unspecified positive integer n, and then prove that it must also hold for n + 1. In the second form, we have one (or more) base cases, and for the induction step we assume that the theorem is true for every positive integer from 1 to an unspecified positive integer n, and then prove that it must also hold for n + 1. [9] b. Recall that x is the largest integer that is x, that x is the smallest integer that is x, and that x R +, x/2 + x/2 = x. Let p 1, p 2, p,... be a sequence of integers defined by p 1 = 0, p 2 = 1 and p n = p n/2 + p n/2 + 1 for all n Z + where n. For example, p = p /2 + p /2 + 1 = p 1 + p 2 + 1 = 0 + 1 + 1 = 2 Prove that for all nonnegative integers n 1, p n = n 1. You must state the induction hypothesis clearly.

page 6 First we need to prove the base cases: p 1 = 0 which is indeed 1 1 and p 2 = 1 which is 2 1. Now consider an unspecified positive integer n, and suppose that p k = k 1 for every k in the interval 1 k < n. p n = p n/2 + p n/2 + 1 = ( n/2 ) 1) + ( n/2 ) 1) + 1 by the induction hypothesis = ( n/2 + n/2 ) 1 1 + 1 = n 1 as required. This completes the induction step and the proof of the theorem. [10] 11. Consider the set L of all strings over the alphabet {a, b, c, d} that start and end with the same letter, and do not contain this letter in any other position. For instance, the strings a, bb and cabbac belong to L, but the empty string and the strings acccb and cabcbac do not. [7] a. Design a DFA that accepts every string in L, and reject every other string. [] b. Write a regular expression that matches exactly the strings that belong to L. ^(a b c d a[bcd]*a b[acd]*b c[abd]*c d[abc]*d)$