Dr. Timo de Wolff Institute of Mathematics www.math.tamu.edu/~dewolff/Spring16/math302.html MATH 302 – Discrete Mathematics – Section 501 Homework 5 Spring 2016 Due: Wednesday, March 9th, 2016, 4:10 pm. When you hand in your homework, do not forget to add your name and your UIN. Exercise 1. Set operations then have a long runtime in computers. Thus, storing sets without an ordering in a computer is not very effective. An alternative way is to represent finite sets is to equip the universal (countable) set U = {a1 , . . . , ak } with an arbitrary total ordering a1 < a2 < . . . < ak and represent the particular set by a k-tuple with entries 0 and 1. We call such tuples 01-vectors. More precisely, the j-th entry of a such a tuple is 1 if and only if the j-th element of the universe, aj , is contained in the particular set, which is represented by the tuple. The j-th entry is 0 otherwise. In practise, one represents sets A1 , . . . , Ar by k-tuples, where k is the maximal element in A1 ∪ · · · ∪ Ar . 1. Let A := {2, 4, 5, 7} and B := {1, 2, 3, 5}. Represent both sets as well as A ∩ B, A ∪ B and A \ B as k-tuples with entries 0 and 1. 2. Let k ∈ N be fixed. Write a pseudocode that takes two sets A, B ⊆ {0, . . . , k} as input and returns A ∩ B such that the computation is done via the 01-vector representation discussed above. That means, you need to translate two times in your program. Exercise 2. For a function f : A → B the graph G(f ) of f is the set {(a, b) : a ∈ A and f (a) = b} ⊆ A × B. 1. Give the graphs for f : {0, . . . , 5} → Q, x 7→ x3 and g : {0, . . . , 5} → N, n 7→ fibn , where fibn denotes the n-th Fibonacci number. 2. Draw the graph of the function f : R → R, x 7→ x3 . Explain, why the graph defined here coincides the usual notion of the graph of a function that you know e.g. from your calculus lectures. 3. Show: if f : A → B and g : B → C and g ◦ f is their composition, then G(g ◦ f ) = {(a, c) : ∃ b ∈ B : (a, b) ∈ G(f ) and (b, c) ∈ G(g)}. 1 Exercise 3. The floor function ⌊·⌋ : R → Z assigns to every real x the largest integer k, which satisfies k ≤ x. 1. Show that for every x ∈ R there exists a maximal k ∈ Z such that 0 ≤ x − k < 1. I.e., ⌊·⌋ is well defined. 2. Write a pseudocode for the floor function. Do not use a short operation like ⌊·⌋ := x − (x%1); use only elemental methods. 3. Show that the floor function is surjective but not injective. Hint: Essentially, 1. solves 2. and vice versa. Make use of that! 2