Download Final Exam - First-Year Interest Group Seminar | N 1 and more Exams Health sciences in PDF only on Docsity! Final Examination CS 336 1. The important issue is the logic you used to arrive at your answer. 2. Use extra paper to determine your solutions then neatly transcribe them onto these sheets. 3. Do not submit the scratch sheets. However, all of the logic necessary to obtain the solution should be on these sheets. 4. Comment on all logical flaws and omissions and enclose the 1. [10] For , how many permutations of 1, 2, 3, ..., n are there in which the odd positions have only odd numbers and the even positions have only even numbers? For example, for n = 5, the permutations <1, 4, 3, 2, 5> and <3, 2, 1, 4, 5> are allowed but <1, 3, 2, 4, 5> is not. (Hint: You may want to do a separate analysis for even n and odd n.). n ≥ 1 comments in boxes 2. [10] A multiset is a generalization of the concept of set and allows multiple copies of its elements. (For example, the multiset { }, ,a a b is distinct from the multiset { }, ,a b b since the first has two copies of and only one copy of yet the second has two copies of b and only one copy of .) The cardinality of a multiset is the total number of elements counting copies (thus the cardinality of multisets a b a { }, ,ba a and { }, ,a b b is three). Assuming and , using elements from the set { , how many multisets are there of cardinality ? 1n ≥ 0m ≥ m 1, }na a..., 3. a. [10] Using a combinatorial argument, prove that for k m≥ ≥ 1 : k m k m k m + = − + 1 1 . b. [10] Using a combinatorial argument, prove that for : n ≥ 1 k n k n n k n n nk n − = − − = ∑ 1 2 1 1 (Hint: Let A and B be disjoint sets of cardinality n. Consider pairs <C, a> where C A B⊆ ∪ , C has cardinality n, and a C A∈ ∩ .) 4. a. [10] Given a set with , what is the probability that a subset of size k has and a ? (You may assume and all subsets of size k are equally prob- able.) { }A a a an= 1 2, , ..., 2 n ≥ 3 2a1 k ≥ . b. [10] Given a set with , what is the probability that a subset of size k has and given that it has at least one of a , a , or ? (You may assume and all subsets of size k are equally probable.) { }A a a an= 1 2, , ..., n ≥ 3 a1 a2 1 2 a3 2k ≥ 5. [10] Let denote the set of natural numbers and { , , }A a b c= . Using only definition 2’ and no cardinality theorems, prove that A× is infinite. 6. [10] Consider this theorem (that relies upon the Axiom of Choice): If , then there exists a subset of such that : ontof A B→ Â A 1 1ˆ: ontof A B −→ . Use this theorem to prove: If , and is infinite then is infinite. : ontof A B→ B A 7. [10] We define if and only if f = Θ( )g gf = Ο( ) and g f= Ο( ) . Prove that n n n+ =1 17Θ +12( ) . 8. [10] Prove that if and f O g1 = ( )1 2f o g2 = ( ) , then f f o g g1 2 1 2⋅ = ⋅( ) . 9. [10] Using Hoare Axioms prove correct with respect to precondition “true” and post- condition : (Assume a, b, c, and t are integer variables and that a, b, and c are de- fined.) c b a≤ ≤ if (a < b) then t := a a := b b := t endif if (b < c) then t := b b := c c := t if (a < b) then t := a a := b b := t endif endif