Mohamed G. Gouda CS 311 Fall 2013 Midterm 3 1) Let f:A->B be a function. a) Prove by direct inference that (f(A) sub B) b) Prove by direct inference that ((f is surjective) => (B sub f(A))) Sol.: a) y in f(A) => {definition of f(A)} (y in B) and (Exist x in A, f(x) = y) => {property of "and"} y in B b) y in B => {f is surjective} (Exist x in A, f(x) = y) => {definition of f(A)} y in f(A) 2) Let f:A->B be a function where set B is finite. Use direct inference and the two predicates (f(A) sub B) ((f is surjective) => (B sub f(A))) to prove the predicate ((f is surjective) => (|B| = |f(A)|)) Sol.: (f is surjective) => {the two given predicates} (f(A) sub B) and (B sub f(A)) => {definition of set equality} B = f(A) => {B is finite and so f(A) is finite and both |B| and |f(A)| are well-defined} (|B| = |f(A)|) 3) Let f:A->B be a function, where A is the set {x, x', x"}, B is the set {y, y"}. Also let A1 be the set {x}. a) Define function f such that f(A-A1) != (f(A) - f(A1)) b) Define function f such that f(A-A1) = (f(A) - f(A1)) Sol.: a) f(x) = y, f(x') = y, f(x") = y" f(A-A1) = f({x', x"}) = {y, y"} != f(A) - f(A1) = ({y, y"} - {y}) = {y"} b) f(x) = y, f(x') = y", f(x") = y" f(A-A1) = f({x', x"}) = {y"} = f(A) - f(A1) = ({y, y"} - {y}) = {y"} 4) Use the characteristic polynomial method to derive the closed equation for the following recurrence equation: R(0) = 2 (1) R(1) = 0 (2) R(n+2) = 4*R(n) n >= 0 (3) Sol.: From (3), the characteristic polynomial (r^2 - 4 = 0) has two roots: r1 = 2, r2 = -2, and the closed equation is R(n) = x*(2)^n + y*(-2)^n n >= 0 (4) From (1), (2), and (4) we get x = 1 and y = 1 The closed equation is R(n) = 2^n + (-2)^n 5) Show by direct inference that the function f(n) = (n^3 - n^2) is Omega(g(n)) where g(n) = n^3. Sol.: |f(n)| = |n^3 - n^2| = n^3 - n^2 for n > 1 = n^3/2 + n^3/2 - n^2 >= n^3/2 for n > 2 = (1/2) * |n^3| = C * |n^3| for C = 1/2 = C * |g(n)| for K = 2 and C = 1/2