Villanova Computer Science



CSC 1300-003 Discrete StructuresExam 3 April 14, 2015Name:_____KEY___________QuestionValueScore110230330420510TOTAL100No calculators or any reference except your one note card is permitted. If an answer involves a computation that would be very time consuming, you may leave it in a form that just needs final calculation.Please answer questions in the spaces provided. If you make a mistake or for some other reason need more space, please use the back of pages and clearly indicate where the answer can be found. Show your work carefully. Just writing an answer will not do. Show any assumptions, show the steps you took, and show how you came to your answer.Good luck! 1. [ /10] Show, using induction that for any n ∈N, A1∪A2∪?An=A1∩A2∩?An -800735136525002. [ /30] a. [ /5] There are 20 plants in your garden but only enough fertilizer spray to boost 8 of them. How many ways are there to fertilize the plants?Answer: C(20,8) = 125,970.b. [ /5] How many anagrams are there (including those that aren’t dictionary words) of PIES?Answer: All four letters are different, so 4! = 24 anagrams.c. [ /5] At the ice cream store, you need to get 20 quarts of ice cream of assorted flavors for a big Fourth of July block party. There are 15 possible flavors to choose from and you can choose any number of quarts of each flavor (including zero). How many ways are there to choose the flavors?Place 20 slots in a line to indicate the 20 quarts, and place 14 dividers to indicate switches between flavors of ice cream. That gives C(20+14, 14) = C(34,14) possibilities for where the dividers would go.For the remaining questions, consider words made of the alphabet A, B, C, D, E, F.d. [ /5] How many four-letter words contain the subword ACE?Answer: A four-letter word containing ACE has only one other letter in it. That letter can occur at the beginning of the word or the end of the word, and there are six possibilities for that letter. Thus, there are 2 · 6 = 12 words containing ACE.e. [ /5] How many five-letter words contain the subword CAB?Answer: We can have words of three forms: – – CAB – CAB – CAB – –For each of these three possibilities, we have six choices for each of the two remaining letters. Thus, the total number is 3 · 62 = 108.f. [ /5] How many four-letter words begin with C or end in two vowels?Answer: If a four-letter word begins with C, then there are six choices for each of the other three letters and so there are 63= 216 such words.If a four-letter word ends in two vowels, there are six choices of letter for the first two letters and two choices of letter (A or E) for the last two letters, for a total of6 · 6 · 2 · 2 = 144 words.This double-counts those words that begin with C and end in two vowels. There are 6 · 4 = 24 such words because there are one, six, two, and two choices for the word’s four letters, respectively. Thus, there are 216 + 144 ? 24 = 336 four-letter words that begin with C or end in two vowels.3. [ /30] a. [ /5] Recall that the Fibonacci sequence is defined by the recurrence Fn = Fn?1 + Fn?2 with initial conditions F0 = 0 and F1 = 1. Write out the three Fibonacci numbers after 34 and 55.After 34, 55: 89, 144, 233b. [ /10] Consider binary numbers with n digits (e.g., 1010, 00101, 011). How many binary numbers of length n do not contain the substring 000? Denote this number by zn; find a relationship between zn, zn?1 , and (we’re not going to tell you) in order to form an appropriate recurrence relation. DO NOT try to find a closed form, just write the recurrence and initial conditions and be sure to explain your reasoning.Answer: Binary numbers with n digits can be categorized into disjoint sets as follows by considering their start bits. They may start with 1 or 0, but if they start with 0, that cannot be part of a 000 group, so it needs to continue as 01xxx…. or 001xx…. (note that 01xxx… covers both the cases of 010xx… and 011xx…). To summarize, we have the following possibilities:start with 1 => there are zn-1 of these that do not contain 000start with 01 => there are zn-2 of these that do not contain 000start with 001 => there are zn-3 of these that do not contain 000nan = -2an?1 + 3an?2an=4-3)n+5 094+5 = 91-74(-3)+5 = -7214+ 27=414(9)+5=413-82-21=-1034(-27)+5=103No other possibilities exist, and these sets are disjoint, so the sum rule applies and we have the recurrence: zn= zn-1+zn-2+zn-3. [alternatively, you can think of analyzing this in terms of ending in 1, 10, or 100]Initial conditions: z0=1, z1=2, and z2=4. Sequence: 1, 2, 4, 7, 13, 24, 44, ... .c. [ /15] Find a closed form for the recurrence an = -2an?1 + 3an?2 , with initial conditions a0 = 9, a1 = -7. Verify your solution for n = 0, 1, 2, 3.Characteristic equation is x2+2x ?3 = 0 with roots x1=-3 and x2=1, so the closed form is an = q1 (3)n + q2 (1)n Using initial conditions: a0 = 9 = q1 + q2 so q1 = 9 ?q2 ; a1 = -7 = -3q1 + q2 = -3(9 ?q2 )+ q2 so q2 = 5 and q1 = 4Thus the closed form is: an=4-3)n+5 4. [ /20] a) [ /5] Suppose a graph G has 365 vertices and 364 edges. Can it be a tree? Must it be a tree?Yes, it can be a tree – as long as it is connected. If it is not connected, it might have cycles, so it is not necessarily a tree. b) [ /5] Draw all trees of five vertices.c) [ /5] Does every bipartite graph have a perfect matching?Answer: No. Consider a bipartite graph with one vertex in the first part and two vertices in the second part.d) [ /5] Make a binary search tree for this list of words. Place the first item shown at the root. Insert the other items in the order in which they appear.it, is, never, too, late, to, have, a, happy, childhood066041005. [ /10] Find the minimum spanning tree. Show your individual steps, i.e., keep redrawing what you have done before, to show how the spanning tree evolves.-45720054102000For your reference, as needed: ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download