Final Exam Fall2013

Embed Size (px)

Citation preview

  • 8/12/2019 Final Exam Fall2013

    1/7

    SGDM E2013 Discrete MathematicsJanuary 2014

    Final Exam Name: Answer Key

    Instructions. (50 points) This exam consists of open ended questions and also multiple choicequestions. Write all your answers on the separate carbon paper. In multiple choice questions,you are requested to choose the correct answer from the options listed, but also to include abrief justication (or calculation, if any) for your chosen answer.

    (3pts ) 1. Prove that the following two formulas are tautologies:

    i) (( p q ) ( p q )) pii) (( x.(Q(x) P (x))) y. P (y))

    Solution : For the rst formula we use a truth table:

    p q p q p q ( p q ) ( p q ) (( p q ) ( p q )) pT T T T T T

    T F F F T T F T T F F T F F T F F T

    and for the second one we use the denition of the negation of propositional connectivesand quantiers, so that we have:

    (( x.(Q(x) P (x))) y. P (y)) ( x.(Q(x) P (x))) ( y. P (y)) ( x. ( Q(x) P (x))) ( y. P (y)) ( x. ( Q(x) P (x))) ( y.P (y))

    Then we can see that there are two possibilities. First, if we have y.P (y), then the formula

    is valid. In the other case, we have y. P (y), and therefore y. ( Q(y) P (y)), so thatthe formula is also valid.

    (3pts ) 2. Consider the function f inductively dened as follows:

    f (0 ) = 1 , f (1) = 1, f (2 ) = 2 ,and f (n) = f (n 1) f (n 3) for any n 3

    This is an inductive denition with three base cases, we can consider some small values forn to get an idea of what f does, and we can prove some properties of f by induction.

    i) compute f (3), f (4) and f (5),

    ii) prove that for any n 2, the value f (n) is an even number.Solution : The values for n = 3 , 4, 5 are the following:

    f (3) = f (2) f (0 ) = 2 1 = 2f (4) = f (3) f (1 ) = 2 1 = 2f (5) = f (4) f (2) = 2 2 = 4

    To prove that f (n) is even for any n 2, it is sufficient to use a simple induction on n.The base case happens when n = 2, and the result is immediate since f (2) = 2 whichis even. Then, in the general case, we have f (n) = f (n 1) f (n 3) and f (n 1) iseven by induction hypothesis. Therefore, f (n) must be even. Using a strong induction isalso possible, but unnecessary since the multiplication of an even number by any numberis even.

  • 8/12/2019 Final Exam Fall2013

    2/7

    SGDM E2013 Discrete Mathematics/Final Exam Page 2 of 7

    (4pts ) 3. Full binary trees are inductive structures dened by one base element and one constructorwith two arguments, denoted by L and N respectively, which represent leaves and internalnodes. The set B of full binary trees is thus dened by:

    L B and N(T 1, T 2) B if T 1 B and T 2 B

    The root of such a tree is either L if the tree has only one node, or the node N(T 1, T 2) suchthat all other nodes of the tree are contained in T 1 or T 2. A branch is a path from the rootto some leaf. The height of a full binary tree T , denoted by h(T ), is dened as the numberof nodes found in the longest branch of T , excluding the root. For example, the height of N(L , N(L , L )) is 2. Finally, we denote by n(T ) the number of nodes (both leaves and internalnodes) in a full binary tree T .

    i) given inductive denitions for h(T ) and n (T ) for any T ,ii) prove that for any full binary tree T we have h(T ) < (n(T ) + 1) / 2.

    Solution : The inductive denitions for h(T ) and n (T ) are:

    h(L ) = 0 h(N(T 1, T 2)) = max (h(T 1), h(T 2)) + 1

    n(L ) = 1 n(N(T 1, T 2)) = n(T 1) + n(T 2) + 1

    Then, to prove that for any T we have h(T ) < (n(T )+1) / 2, we use a structural induction onT . The base case happens when T contains only one node, so that h(T ) = 0 < 1 = n(T ). Inthe general case, by induction hypothesis h(T 1) < (n(T 1)+1) / 2 and h(T 2) < (n(T 2)+1) / 2,so that we can conclude by considering the two possible cases. If h(T 1) > h (T 2) then wehave:

    h(T ) = h(T 1) + 1 < ((n(T 1) + 1) / 2) + 1< (n(T 1) + 3) / 2< (n(T 1) + n(T 2) + 2) / 2< (n(T ) + 1) / 2

    since we have n (T ) 1 for any T and thus in particular n(T 2) 1. The other case, whenh(T 2) h(T 1) is the same except that we start from h(T 2) and n(T 2).

    (3pts ) 4. Suppose f : Z+ {0, 1, 2, 3} satises

    f ( j ) =

    0 if 7 j, 3 | j,1 if 7 | j, 3 j,2 if 21 | j,3 otherwise

    where Z + = {0, 1, 2, . . .} is the set of positive integers, a | b denotes that a divides b, anda b denotes that a does not divide b.(a) f is a bijective function(b) f is not a function(c) f is a function which is neither one-to-one nor onto(d) f is a function which is not one-to-one, but it is ontoSolution : f is a function because each value in the domain Z+ has at most one image inthe codomain {0, 1, 2, 3}. It is onto because all values in the codomain {0, 1, 2, 3} are theimage of some element in the domain, and it is not one-to-one because there are more thanone element in the domain having the same image.

  • 8/12/2019 Final Exam Fall2013

    3/7

    SGDM E2013 Discrete Mathematics/Final Exam Page 3 of 7

    (2pts ) 5. The rst term of an arithmetic progression is a0 = 1, and we also know that the term a11is a11 = 23. Find the term a20 of the progression.(a) a20 = 39(b) a20 = 41(c) a20 = 42(d) There is not enough information.Solution : Every term is dened as an = a + nd in an arithmetic progression. From a0 =1 = a + 0 d we know that a = 1, and from a11 = 23 we know that 1 + 11 d = 23, that is,d = 2. Therefore, a20 = 1 + 20 2 = 41.

    (2pts ) 6. Given the following relations on the set {1, 2, 3, 4},R1 = {(1, 1), (2, 2), (3, 3), (4, 4)}R2 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}R3 = {(1, 1), (1, 2), (1, 4), (2, 2), (2, 4), (3, 3), (4, 1), (4, 2), (4, 4)}

    (a) R2 and R3 are transitive

    (b) R1 and R2 are equivalence relations(c) R3 is symmetric but not transitive(d) None of the above solutionsSolution : The answers (a) nor (c) are incorrect because R3 is neither transitive (becauseof having the elements (2 , 4) and (4 , 1), the element (2 , 1) should also be in the relation forR3 to be transitive) nor symmetric (because of having the element (1 , 2), again the element(2, 1) should be in the relation for R3 to be symmetric). But the answer (b) is correct:both relations R1 and R2 are symmetric, transitive and reexive, thus they are equivalencerelations.

    (3pts ) 7. Let R = {(1, 2), (2, 3), (3, 4)} be a relation on the set {1, 2, 3, 4}. What is the transitive

    closure of R?(a) {(1, 2), (2, 3), (3, 4), (2, 1), (3, 2), (4, 3)}(b) {(1, 2), (2, 3), (3, 4), (1, 3), (2, 4)}(c) {(1, 2), (2, 3), (3, 4), (1, 3), (2, 4), (1, 4)}(d) {(1, 2), (2, 3), (3, 4), (1, 4)}Solution : Because of having the elements (1 , 2) and (2 , 3), then the element (1 , 3) should bein the transitive closure. From the elements (2 , 3) and (3 , 4), also the element (2 , 4) shouldbe in the transitive closure. Finally, from the elements (1 , 2) and (2 , 4), we have that theelement (1 , 4) should also be in the transitive closure.

    (3pts

    ) 8.

    Six presidents from the countries A, B, C , D, E and F are attending an important in-ternational event. The event is coming to an end, and they want to decide which one of them will organize the next event. They want the next organizer to be in harmony withthe highest number of presidents as possible. For this reason, they decide to choose thatpresident having met with more presidents.President A claims to have had 1 meeting with some other president, president B claims tohave met with 2 other presidents, president C claims to have had 3 meetings, president Dclaims 2 meetings, president E claims 4 meetings and, nally, president F claims to havehad 3 meetings. In this context, a meeting is always assumed to be one-to-one. Clearly,president E seems to be the next organizer of the international event. But... has anyonecheated? Consider justifying the answer in terms of graphs. Be brief but precise.

    Solution : We can represent this exercise as a simple graph in which each president isa vertex and an edge between vertices A and B represents a meeting between president

  • 8/12/2019 Final Exam Fall2013

    4/7

    SGDM E2013 Discrete Mathematics/Final Exam Page 4 of 7

    A and president B. This means that the number of meetings that each president hashad corresponds to the degree of the vertex representing that president. Therefore, thisproblem is asking whether there exist a graph having |V | = 6, and whose vertices havedegrees 4, 3, 3, 2, 2, 1. By the Handshake Theorem , this graph cannot exist because the sumof the degrees of all vertices should be an even number. This means that some president has

    cheated when claiming how many meetings he had. Note that there is no way of knowingwho of them cheated, and it might have been the case that more than one did.

    (2pts ) 9. A connected and planar graph having 15 vertices divides the plane into 12 regions. Whatis the number of edges connecting the vertices in this graph?(a) 15(b) 24(c) 25(d) There is not enough information.Solution : We use here Eulers formula R = E V + 2, where R is the number of regions,E is the number of edges, and V the number of vertices of the graph.

    (2pts ) 10. Consider the alphabet = {a,b,c} and the language L on dened as the following set:

    { (a + b)n ck an +1 | n, k N }

    where (a + b) denotes a symbol that is either a or b, as in regular expressions. Note thatto be more formal we could write { w | n, k N, w (a + b)n ck an +1 } to describe the samelanguage, thus formally using regular expressions. Which one of the following grammarsin BNF (all with initial symbol S , and where is the empty string) generates exactly thewords of this language?(a) S ::= Ra R ::= aRa | bRa | Q Q ::= cQ | (b) S ::= R | Q R ::= aRa | bR | Q Q ::= Qc | a(c) S ::= aS | bS | R R ::= cR | Q Q ::= aR | a(d) S ::= R | Q R ::= aS | bS Q ::= Rc | RaSolution : A good methodology is to proceed by elimination. First, the grammar (d) is notterminating because all of its productions contain at least one non-terminal symbol (so it isimpossible to produce any nite word). Then, in grammar (c), we can obtain the followingderivation:

    S R cR cQ caR cacR cacQ caca

    thus producing a word that is not in the given set (since it contains an alternance of a andc symbols). Finally, using grammar (b) we can obtain the derivation:

    S R bR bQ ba

    wich ends in a word that is not in the given set (there should be one more a for the countdescribed by n and n + 1 to match). We can therefore conclude that (a) is the rightgrammar, where S guarantees the presence of the last a and R introduce always as manya or b at the begininng as a at the end, while Q is only concerned with the introduction of an arbitrary number of c symbols.

  • 8/12/2019 Final Exam Fall2013

    5/7

    SGDM E2013 Discrete Mathematics/Final Exam Page 5 of 7

    (4pts ) 11. Write a deterministic nite-state automaton that accepts a word w on the alphabet {0, 1}if and only if w has the following shape:

    1odd number of 0s

    0 0 1odd number of 0s

    0 0 1odd number of 0s

    0 0 1that is, if w ends with a 1 and is otherwise composed of arbitrarily many blocks formed of a 1 followed by an odd number of 0s (for example, the words 1000101 and 1010000010001are accepted, but neither 10001101 nor 1001000001).Solution : We describe the automaton by its transitions ( sc , e , s d ), where sc is the currentstate, e is the symbol read and sd is the destination state. These transitions are:

    (s0, 1, s1) (s1, 0, s2) (s2, 0, s3) (s2, 1, s1) (s3, 0, s2)

    and its initial state is s0, the unique accepting state being s1. The idea is that the word canbe a single 1, so after reading 1 we get to s1 which is an accepting state, and any additionalblock 0 01 is treated by states s2 and s3, which are simply ensuring that an even number

    of 0 are read before a 1 leads back to s0.

    (4pts ) 12. Consider a Turing machine using the alphabet {0, 1, } and the blank symbol B , describedby the following transitions, represented as ve-tuples (which give the source state, theinput, the destination state, the output and the direction):

    (s0, 0, s1, ,L ) (s0, 1, s2, ,L ) (s0, , s 0, ,R ) (s0,B , s 4,B ,L )(s1, , s 1, ,L ) (s1, 0, s1, 0, L) (s1, 1, s1, 1, L) (s1,B , s 3, 0, R)(s2, , s 2, ,L ) (s2, 0, s2, 0, L) (s2, 1, s2, 1, L) (s2,B , s 3, 1, R)(s3, 0, s3, 0, R) (s3, 1, s3, 1, R) (s3, , s 0, ,R )(s4, , s 4,B ,L )

    This machine has 5 states, the initial state being s0. It expects a tape containing a string of 0s and 1s only in the beginning, the rest being blank, and the initial position is the leftmostnon-blank symbol, as usual. Given the following tape on which we run the machine:

    | B | B | 0 | 1 | 1 | B | B |

    what is the conguration of the tape after the machine stops?

    (a) | B | B | 1 | | 1 | B | B |

    (b) | B | B | 1 | 1 | 0 | B | B |

    (c) | B | B | 0 | 0 | 1 | B | B | (d) The machine never reaches a halting conguration.Solution : The only way is to perform the actions of the machine, step by step. One canobserve after a few steps that the machine reads either 0 or 1, replaces it with and writesthe number somewhere else on the left. This is repeated and when reading numbers furtheron the right it must move further on the left to nd a blank space to write the number.When all three numbers have been moved, they are placed in reverse order and three symbols are left in the original cells. The last phase cleans up the tape by replacing these

    with the blank symbol, and stops in state s4 when it reaches the rst non-blank symbol(the rightmost number in the resulting reversed string of 0 and 1).

  • 8/12/2019 Final Exam Fall2013

    6/7

    SGDM E2013 Discrete Mathematics/Final Exam Page 6 of 7

    (3pts ) 13. Recall that an ISBN -10 is a 10-digit code x1x2 . . . x 10 used to identify a book uniquely,satisfying

    10

    i=1ix i = 0 (mod 11) .

    The last digit, x10 , is called check digit . The rst nine digits of the ISBN -10 of a book are071954400, what is the check digit?(a) 0(b) 9(c) 10 (X )(d) This ISBN -10 is not valid.Solution : 0 1 + 7 2 + 1 3 + 9 4 + 5 5 + 4 6 + 4 7 + 0 8 + 0 9 + x 10 0 (mod 11)Then we have 130 + x 10 0 (mod 11)9 + x 10 0 (mod 11)Therefore, the check digit is x = 9.

    (2pts ) 14. What is the least common multiple of 540 and 216?(a) 25 36 5(b) 22 33 5(c) 22 32 52

    (d) 23 33 5

    Solution : lcm(540, 216) = lcm(2 2 33 5, 23 33) = 2 max {2,3} 3max {3,3} 5max {1,0} = 2 3 33 5

    (3pts ) 15. Paul wants to send a set of 12 different symbols and 40 blank spaces through a communi-cation channel. These blank spaces should be sent in such a way that there is at least 3blank spaces between any two consecutive symbols, and no spaces are allowed before therst symbol or after the last symbol. How many different ways does he have of sending amessage?(a) 1710 12!(b) 3 4012(c) 117(d) 1811Solution : Since at least 3 blank spaces should be sent between any two consecutive symbols,and there are 12 symbols, we do have 11 wholes between every symbol, which will contain3 blank spaces each. The remaining 40 33 = 7 blank spaces will have to be spread allover the 11 wholes, and there are 11+7 1

    7 = 17

    7 different ways of doing so. Note that

    177 =

    1717 7 =

    1710 . Finally, for each different way of arranging the blank spaces, we also

    have 12! different ways (different orders) of sending the 12 symbols. By the product rule,Paul has 1710 12! different ways of sending a message.

    (2pts ) 16. The owner of a pizzeria prepares every pizza by always combining 4 different ingredients.How many ingredients does he need, at least, if he would like to offer 30 different pizzas inthe menu?(a) 6(b) 7(c) 8(d) 9

  • 8/12/2019 Final Exam Fall2013

    7/7

    SGDM E2013 Discrete Mathematics/Final Exam Page 7 of 7

    Solution : Using 6 different ingredients, he can obtain 64 = 15 different pizzas, while with7 ingredients he gets 74 = 35 different pizzas. Then, since

    64 30

    7

    4 , he needs atleast 7 ingredients.

    (3pts ) 17. A car pool contains 8 Fords (4 red and 4 white) and 12 Pontiacs (2 red and 10 white).

    You are allocated a car at random. You see from a distance that it is red. What is theprobability that you have been given a Ford?(a) 0 .240(b) 0 .375(c) 0.667(d) 0 .833Solution : Let F and R be the event of being a Ford and a red car, respectively. We areasked for P (F |R). There are 20 cars of which 8 are Fords, so P (F ) = 820 = 0 .4, and 6cars are red, so P (R) = 620 = 0 .3. The probability of a red car, given that it is a Ford, isP (R |F ) = 48 = 0 .5. So

    P (F |R) = P (F ) P (R |F )

    P (R )P (F |R) = 0.40.50.3 = 0 .667We could have also used Bayes theorem for this exercise.

    (2pts ) 18. A professor randomly selects three new teaching assistants from a total of 10 applicants: 6male and 4 female students. The probability that no females are hired is(a) 0.167(b) 0 .200(c) 0.250(d) 0 .333

    Solution : There are103 = 120 different ways of picking 3 TAs out of 10 candidates, and6

    3 = 20 different ways of picking 3 men out of the total of 6 male candidates. Thus theprobability that no females are hired is 20 / 120 = 0.167.