Page 7 1 Maximum number of comparisons n-1+n-2+…+1= n*(n-1)/2 Worst case scenario: the list is inversely sorted, from the largest number to the smallest 2 11 12 13 Day 20 Sum=1+2+4+…+2^19=2^20-1 Suppose sum of day n is Sn Sn=1+2+4+…+2^(n-1) 2*Sn=2+4+…+2^(n-1)+2^n =>Sn=2^n-1 Page 17 2. No one to one function Onto functions {(1, a), (2, a), (3, b)}, {(1, a), (2, b), (3, b)}, {(1, a), (2, b), (3, a)}, {(1, b), (2, a), (3, a)}, {(1, b), (2, a), (3, b)}, {(1, b), (2, b), (3, a)} 3. No onto function One to one functions {(1, a), (2, b)}, {(1, b), (2, a)}, {(1, a), (2, c)}, {(1, c), (2, a)}, {(1, b), (2, c)}, {(1, c), (2, b)}. 4 5 if K<=n, the result is P(k,n)=n!/(n-k)!. If k>n, there is no way to satisfy both conditions (pass out all the fruit and one child can get one piece of fruit at most). 8 For both case the answer is the same. It is 2*P(4, 4)* P(4, 4)=1152. 9 {(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1), (1, 2, 4), (1, 4, 2), (2, 1, 4), (2, 4, 1), (4, 1, 2), (4, 2, 1), (1, 2, 5), (1, 5, 2), (2, 1, 5), (2, 5, 1), (5, 1, 2), (5, 2, 1), (1, 4, 3), (1, 3, 4), (4, 1, 3), (4, 3, 1), (3, 1, 4), (3, 4, 1), (1, 5, 3), (1, 3, 5), (5, 1, 3), (5, 3, 1), (3, 1, 5), (3, 5, 1), (1, 5, 4), (1, 4, 5), (5, 1, 4), (5, 4, 1), (4, 1, 5), (4, 5, 1), (4, 2, 3), (4, 3, 2), (2, 4, 3), (2, 3, 4), (3, 4, 2), (3, 2, 4), (5, 2, 3), (5, 3, 2), (2, 5, 3), (2, 3, 5), (3, 5, 2), (3, 2, 5), (4, 2, 5), (4, 5, 2), (2, 4, 5), (2, 5, 4), (5, 4, 2), (5, 2, 4), (4, 5, 3), (4, 3, 5), (5, 4, 3), (5, 3, 4), (3, 4, 5), (3, 5, 4)} 6 permutations to a given three element set. {1,2,3,4,5} has 10 three element subsets. 11 The result is 17 Suppose the domain of f is denoted n-element set A {a1,a2,…,an}. The range of f is denoted by the n element set B {b1, b2,…,bn}. The function f is denoted by f:A->B. First: prove f is one-to-one=> f is onto. Assume f is not onto. There exists an element bi in B that cannot be mapped from any element ai in A by function of f. Therefore the total number of elements in B that can be mapped from an element in A by function of f is at most n-1. It means that n elements of A are mapped to at most n-1 elements of B. Therefore there exist two elements in A that are mapped to the same element bi in B. This contradicts with the premise that f is one-to-one. So the assumption is not right. f is onto. Second: prove f is onto=> f is one-to-one. Assume f is not one-to-one. There exists two elements ai, aj in A such that ai, aj are mapped to the same element in B. Therefore the number of elements in B that can be mapped from an element in A by function of f is at most n-1. But B has n elements. Therefore there exists an element bi in B that is not mapped from any element in A by function of f. This contradicts with the premise that f is onto. Therefore the assumption is not right. f is one to one. 18. a) Suppose f is defined as f:A->B, where A is the domain, B is the range. A is denoted as the set {a1, a2,…, an}, B is denoted as the set {b1,b2, …, bm}. f can also be denoted as the set {(ai,bj)|f(ai)=bj, ai is in A,bj is in B}. First: prove f is a bijection => f has an inverse function. F is a bijection means that f is onto and one-to-one. Thus for every element bi in B, there is a unique element ai in A that corresponds to it. If we inverse each pair (ai, bi) in the original function f, the result relationship is {(b1,a1),(b2,a2),…,(bn,an)}. This new relationship is a function because for each bi in B there is a unique element ai in A that corresponds to it. Assume it is named g. Then g(f(ai))=g(bi)=ai, f(g(bi))=f(ai)=bi. Thus f has an inverse function g. Second: prove f has an inverse function => f is a bijection. Assume f is not a bijection. This means either f is not one-to-one or f is not onto. If f is not one-to-one, there exists two distinct elements ai, aj in A such that ai <> aj and f(ai)=f(aj). Because function f maps an element in A to an element in B, therefore the element that ai, aj that mapped to is also an element in B. We denote this element as bk. According to the definition of inverse function, g(f(ai))=ai, g(f(aj))=aj. Because f(ai)=f(aj)=bk, g((f(ai)))=g(bk)=g(f(aj)). Thus ai=aj. This contradicts with the previous conclusion that ai <> aj. If f is not onto, there exists an element bi in B that cannot be mapped from any element in A by function of f. Because for each element y in the range of f, f(g(y))=y. It means that f(g(bi)) =bi. This means that that there exists an element g(bi) in A that can be mapped to an element bi in B by function of f. This is a direct contradiction to the conclusion that bi cannot be mapped from any elements in A. Therefore in either condition, there is a contradiction. So the assumption is not correct. F is a bijection. b) Assume f has more than one distinct inverse function. Therefore there exists two distinct inverse functions g1, g2 such that there exists a bi in B that g1(bi) <> g2(bi). By definition of inverse function, f(g1(bi))=bi=f(g2(bi)). So there exists two different elements g1(bi),g2(bi) in the domain of f that is mapped to the same element bi in the range of f by function of f. This implies that f is not one-to-one. We have proved in part a) that f has an inverse function if and only if is a bijection. This contradicts with this conclusion. Therefore, the assumption is not right. f cannot have more than one inverse function if it has an inverse function. It means that f has only one inverse function if f has a inverse function.