October 17, 1995 cs330 - Discrete Structures =========================== Fall 1995 Hw #3 - Solutions ================= Note: In the following solutions != means not equal Also note that failure to proof your statements guarantees you at most 50% of the grade for that problem. If the answer is correct you get 50%, if it's wrong you get 0. A wrong answer with an attempted proof may earn you some credit. 20/79 ===== a) Countable because the set is a subset of the set of integer numbers (Z), and we know (see class notes) that every subset of a countable set is countable. b) Countable by the same argument as above. c) Countable: we can list all numbers in the incresing order of their number of decimal places. Ordinal | Number --------|---------------------------- 0 | 0 0 decimal places 1 | 0.1 1 decimal place 2 | 0.11 2 decimal places 3 | 0.111 3 decimal places 4 | 0.1111 4 decimal places : | ...... --------|---------------------------- This proves that the set of real numbers between 0 and 1, with decimal places consisting of all 1s is countable. We can make the same argument for real numbers having the same property in any interval (n, n+1), n an integer. Since Z is countable and we know that (see class notes) that a countable union of countable set is countable, it results that the set of all real numbers whose decimal places are all 1's is countable. If your understanding of the problem is such that you only consider real numbers whose digits are all 1's (like 1.111, 11111.1 etc), then this set is also countable because it is a subset of the set proved above to be countable). d) Countable: use a similar argument with the one at part d. Ordinal | Number --------|---------------------------- 0 | 0 0 decimal places 1 | 0.1 1 decimal place (2 such numbers) 2 | 0.9 3 | 0.11 2 decimal places (4 numbers) 4 | 0.19 5 | 0.91 6 | 0.99 3 | 0.111 3 decimal places (2^3 = 8 numbers) : | ...... --------|---------------------------- this proves the set of real numbers between 0 and 1, with decimal places of only 1s and 9s is countable. Since the integer part of the real numbers with the property that it consist of only 1s and 9s is countable (a subset of Z), it results that we have the countable union of countable sets, which we know is countable. 2/88 ==== a) Yes (it is in fact better, O(x)) b) Yes, by the theorem about polynomials c) Yes (it is in fact better, O(xlogx)) xlogx < x*x = x^2 (for x>0) d) No, since this function is O(x^4) e) No, since the function is O(2^x) f) Yes floor(x) <= x therefore O(floor(x)) = x ceiling(x) <= x+1 therefore O(ceiling(x) = x By the product theorem it results floor(x)*ceiling(x) = O(x^2) 4/88 ==== 2^x + 17 < 3^x + 17 for x>0 < 3^x + 3^x for x>3 = 2*3^x C=2, k=3 and , according to the definition the funtion is O(3^x) 14/88 ===== a) False, since x^3 is O(x^ and x^2 is only x^2 b) True c) True, since x^2 + x^3 is O(x^3) by the theorem about polynomials d) True, since x^2 + x^4 is O(x^4). It's sloppy though. e) True, since x^3 < 3^x for x>3 f) True, since (x^3)/2 is O(x^3) 20/88 ===== a) O(n^3*logn) this can be shown either by doing all multiplications and then using the definition, or by using the product theorem first and then the theorem about the O of sums of functions. b) O(6^n) c) O(n^n * n!) A rougher estimate is O(n^2n) since n! f(x1)!=f(x2) - assume x1 and x2 different and both even f(x1) = x1+1 f(x2) = x2+1 => f(x1)!=f(x2) - assume x1 even (can be written as 2*k) and x2 odd (2*p+1) f(x1) = 2*k+1 f(x2) = 2*p+1-1 = 2*p f(x1)!=f(x2) because an odd number can't be even (f(x2)) surjective: - assume some n in the codomain. If n is even then it's preimage is n+1, an odd number in the domain. If n is odd then it's preimage is n-1, an even number in the domain. Since f is both injective and sujective it results it's also bijective. The inverse of f is f-1 defined as follows: f-1(x) = if x is odd then (x-1) else (x+1) c) injective: - assume some set S and x1, x2 two elements in S, x1!=x2 f(x1) = {x1} f(x2) = {x2} => f(x1)!=f(x2) since the two sets {x1} and {x2} are different as they have different elements. not surjective: the set S itself is an element in power(S), yet it has no preimage. d) not injective: assume S={a, b} f() = {a,a,b,a,a} = {a,b} (no repetitions in a set) f() = {b, a} = {a, b} Since two different elements in the domain (the lists and ) have the same image (the set {a, b}) it results that f is not injective surjective: for each element in the codomain (for each set Si memebr of power(S)) build a corresponding list (preimage) as follows: * for each element in Si if the element is simple then list it in the list; if the element is a set then place a list in the list and list all the elements of the set in that list; Example: assume S={a, {b,c}}. then power(S) = {{}, {a}, {{b, c}}, {a, {b,c}} } Preimages are: {} <> {a} {{b,c}} <> {a, {b,c}} > e) injective: two different arguments will yield list of different lengths, hence different. not surjective: there are lists that have no preimage like <0,0,0,0> f) injective: two different arguments will yield two different lists - assume x1!=x2, then f(x1, ) = <, , ..., f(x2, ) = <, , ..., The two lists are different since != not surjective: there are lists in lists(AxB) that have no preimage, e.g. the lists where individual sub-lists do not have the same head. Example: A={1, 2} B={a, b} the list <<1,a>,<2,a>> does not have preimage since <1,a> and <2,a> do not have the same head (same first element).