Discrete Structures, CSCI 246, Fall 2015 Final, Dec. 10 Indicate the option which most accurately completes the sentence. 1. Say that Discrete(x) means that x is a discrete structures exam and Well(x) mean that I did well on exam x. Which best describes the statement x (Well(x) Discrete(x)) (3 pts.) a. I do well whenever it is a discrete structures exam b. All exams are discrete structures exams and I do well on them c. If I did well on the exam then it was a discrete structures exam d. I did well on the exam only if it was a discrete structures exam e. None of the above 2. Let R be a relation on the set of all web pages where (a, b) R if and only if there is at least one common link on web page a and web page b. Which best describes the relation R? (3 pts.) a. reflexive b. symmetric c. transitive d. reflexive and symmetric e. none of the above 3. Which best describes what is mean by an undirected graph G being k-vertexconnected. (3 pts.) a. The graph remains connected after any k-1 vertices are removed from the graph b. The graph remains connected after any k vertices are removed from the graph c. The graph is no longer connected when any k-1 vertices are removed from the graph d. The graph is no longer connected when any k vertices are removed from the graph e. None of the above 4. An equivalent way of writing p q is (3 pts.) a. q p b. p q c. p q d. p q e. All of the above 5. The function f(x) = x 2-9 on the real numbers is (3 pts.) a. is a bijection b. is 1-1 but is not onto c. is onto but is not 1-1 d. is not 1-1 and is not onto e. is not a function 1
6. How many functions are there from a five-element set {a, b, c, d, e} to the two element set {t, f}. Please give a numeric answer and show your work. 2 5 =32 Five positions, two choices for each 7. There are 17 questions on this exam (don t count the extra credit). Say that you get 15 of these questions correct and two wrong. How many patterns of 15 correct and 2 incorrect are possible? Please give a numeric answer and show your work. C(17, 15) = C(17, 2) = 136 ways 8. How many strings of four decimal digits do not contain the same digit twice? Please give a numeric answer and show your work. 10*9*8*7 = 5,040 strings 9. What is the coefficient of x 7 in (2-x) 10? Giving a formula for the answer is sufficient. You do not need to arrive at a final numerical answer. The term will be C(10,7) * 2 10-3 * (-x) 7, so the coefficient will be C(10,7)*2 7 *(-1) 7 = 120 * 128 * -1 = - 15,360 2
10. Is the relation = { (a, b) a and b have the same parents} an equivalence relation? Why or why not? It is an equivalence relation because it is reflexive (a person has the same parents as itself), symmetric (if a and b have the same parents then b and a have the same parents) and transitive (if a and b have the same parents, and b and c have the same parents, then a and c have the same parents) 11. Draw a picture of G+ for the digraph: 12. Give the spanning tree of the following graph when starting at vertex A and doing a depth-first search. 3
13. Let W(x) be the statement x is working properly and A(x) be the statement x has access to the world wide web where the domain consists of all computers. Express the following in English. x(w(x) A(x)) There is a computer which, if it is working properly, does not have access to the world wide web. This is tricky 14. Tell if the following proof is valid. If the proof is not valid carefully explain why not. Every postage of three cents or more can be formed using just three-cent and fourcent stamps. Basis step: We can form postage of three cents with a single three-cent stamp and we can form postage of four cents using a single four-cent stamp. Inductive step: Assume that we can form postage of j cents for all nonnegative integers j with j k using just three-cent and four-cent stamps. We can then form postage of k+1 cents by replacing one three-cent stamp with a four-cent stamp or by replacing two four-cent stamps by three three-cent stamps. This proof is not valid. This proof says that every postage of thee cents or more can be formed using just three-cent and four-cent stamps, however, 5 cannot be formed using just 3 cent and 4 cent stamps. The problem with the proof is that there are not necessarily two four-cent stamps to remove. This might be better as an extra credit problem but it is a very easy extra credit. 4
15. A computer network consists of six computes. Each computer is directly connected to at least one of the other computers. Show that there are at least two computers in the network that are directly connected to the same number of other computers. (10 pts.) Let the boxes of the Pigeonhole Principle be the number of connection a computer has, that is, the number of other computers the computer is connected to. Since each computer must be connected to at least one other computer, the possibilities are 1, 2, 3, 4, or 5 connections. Since there are 6 computers (pigeons), and only 5 possible connection numbers (boxes), the Pigeonhole Principle tells us that two computers must have the same number of connections. 5
16. Prove the theorem of unique paths in trees. Theorem: There is a unique path between every pair of vertices in a tree. (10 pts.) This will be proved by contradiction. Suppose, by way of contradiction, that the proof is not true. Then there is not a unique path between every pair of vertices. It must be true that either there is not a path, or the path is not unique. Case 1: There is not a path between two sets of vertices. This is impossible because trees are connected. Thus this is not the case. Case 2: The path between a pair of vertices is not unique. Then there must be at least two paths between a pair of vertices. This would create a circuit. Since trees do not contain circuits, there cannot be two of more paths between a pair of vertices. Since both cases create a contradiction, the proof must be true. 6
17. Following is a recursive algorithm for finding the product of the first n positive integers. int recproduct(n) { if (n<=1) return 1; else return n * recproduct(n-1); } Use mathematical induction to prove that the recursive algorithm is correct. Note that more partial credit will be given if you define a shortcut P(n), tell what you are going to prove, tell how you are going to prove it, prove the statement stating all assumptions clearly, and end with a statement that you have proved what you intended to prove. (20 pts.) Let P(n): recproduct(n) returns Prove P(n) for n 1. n i=1 This will be proven using mathematical induction Proof: Basis: Show that P(1) holds. Statement Reason 1. recproduct(1) returns 1 See code (Definition of recproduct) n 2. " returns i=1 i Property or definition of product Induction: Assume P(n) holds for n 1 Show P(n+1) holds i Statement 1. recproduct(n+1) returns (n+1) * recproduct(n) n 2. " returns (n+1) * i i=1 Reason Definition ofrecproduct Inductive hypothesis n+1 3. " returns i=1 i Definition of product Thus by the Principle of Mathematical induction, P(n) holds for n 1. 7
Extra Credit 18. Prove that a forest with c components and n vertices has n-c edges. Assume n c. (Hint: the base case will have n=c.) This will be proven using mathematical induction. Let P(n) stand for the statement: In a forest with c components and n vertices, # edges = n-c Prove that P(n) holds for n c Basis: Show P(n) for n=c. A forest with c components and n vertices, where n=c, is simply n isolated vertices. Since all vertices are isolated, there are no edges. Thus #edges = 0 = n-n = c-n Induction: Assume P(n) for n c Show P(n+1). We are assuming P(n), that in a forest with c components and n vertices, # edges = n-c We need to show P(n+1), that in a forest with c components and n+1 vertices, # edges = (n+1)-c Consider a forest with c components and n+1 vertices. I want to remove one vertex from this forest. There are two possibilities: Case 1: If there is an isolated vertex, remove it. Case 2: If there is no isolated vertex, all trees have at least 2 vertices. Remove a leaf from one of the trees. In case 1, an isolated vertex was removed, creating a smaller tree with one less component (since the isolated vertex was itself a component) and one less vertex. By the induction hypothesis: # edges in smaller tree = ((n+1)-1) - (c-1) Since no edges were removed when creating the smaller tree, the number of edges in the original tree will be the same as the number of edges in the smaller tree. Thus, # edges in original tree = ((n+1)-1) - (c-1) = n (c-1) =(n+1) c 8
In case 2, a leaf was removed from one of the trees, causing both a vertex and an edge to be removed. This created a smaller tree with one less edge and the same number of components. By the induction hypothesis: # edges in smaller tree = ((n+1)-1) - c Since one edge was removed when creating the smaller tree, the number of edges in the original tree will be one more than the number of edges in the smaller tree. Thus, # edges in original tree = 1+ ((n+1)-1) - c = (n+1) c Thus, by the Principle of Mathematical Induction, P(n) holds for n c. 9