computing fundamentals i exercise sheet 1 answers

Upload: davegreenwood

Post on 06-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Computing Fundamentals I Exercise Sheet 1 Answers

    1/4

    CMPC1F02 Computing Fundamentals IExercise Sheet 1 Answers

    1. Write out in terms of an explicit list the following sets:

    (a) A = {x : x is a prime number, 10 x 30}(b) B is the set of days in the week that begin with an S.(c) C = {x : x = 2 y for some yN , 1 x < 14}(d) D = {x : xZ , |x| 2}Answers:(a) A = {11, 13, 17, 19, 23, 29}(b) B = {Saturday, Sunday }(c) C = {2, 4, 6, 8, 10, 12}(d) D = {2, 1, 0, 1, 2}

    2. Find the cardinalities of the following sets:(a) A =

    {x : x is a prime number, 10

    x

    23

    }(b) B = {x : xN , x < 10}(c) C = {x : xZ , 1 x 2 10}(d) D = {x : xZ , |x| 3}

    Answers:(a) |A| = 5 because A = {11, 13, 17, 19, 23}(b) |B | = 0 because there are no natural numbers less than zero.(c) |C | = 6 because C = {1, 2, 3, 1, 2, 3}(d) |D | = 7 because D = {1, 2, 3, 0, 1, 2, 3}3. Let A = {x : xN and 1 < x < 50}, B = {x : xR and 1 < x < 50}, and C =

    {x : xZ and |x| 25}. Which of the following statements are true? For thosethat are not true, why not?(a) B A

    (b) 17A

    (c) 3A(d) 40C (e) {0, 1, 2} A(d) |C | = 26

    1

  • 8/2/2019 Computing Fundamentals I Exercise Sheet 1 Answers

    2/4

    Answers:(a) False. There are innitely more real numbers than natural numbers.(b) True. 17 is a natural number within the range.(c) False. The square root of 3 is not a natural number.(d) False. -40 is an integer but is outside the specied range.(e) True, provided 0 is considered a natural number, else false.(f) False. |C | = 51.

    4. Let U = {x : x Z , 5 x 6}. Suppose A = {4, 1, 3, 1, 4, 6}, B ={2, 3, 6}, and C = {2, 4, 1, 6}.

    (a) What are AC, A B C, (A B )C, and (A C )B ?(b) Represent each of the four sets given in part (a) as a Venn diagram.

    Answers:

    A

    C = {4, 1, 3, 1, 4, 6, 2} A B C = {6}

    (A B )C = {4, 1, 1, 4, 6, 2} (A C )B = {1, 2, 3, 4, 6}5. In a rst year class of computing science school comprising of 50 students, 30 study

    C++, 25 study Perl, and 10 study both. How many students study neither C++nor Perl?

    2

  • 8/2/2019 Computing Fundamentals I Exercise Sheet 1 Answers

    3/4

    Figure 1: A total or 18 people like Dance Music.

    Answer:

    Note that 10 study both, which is the intersection of Perl and C++, so (30 - 10) just study C++, and (25 - 10) just study Perl, leaving 5 studying neither.

    Therefore: 50 - (30 -10) - (25 -10) - 10 = 5.

    6. In a group of 24 people who like rock, punk, or dance music, 14 like rock, 17 likepunk, 11 like rock and punk, 9 like rock and dance, 13 like punk and dance, and 8like all three types of music. How many like dance music?

    Answer:

    Using the Venn Diagram shown in Figure 1, and starting with the intersection of all three sets is 8, by elimination the total number of people who like dance music

    is 18.And from the principles of inclusion and exclusion:

    |AB C | = |A|+ |B |+ |C | |A B | |A C | |B C |+ |A B C |7. Use the laws of set theory to simplify the following:

    (a) (A B )(A B )(b) AB (A B C )

    Answer:

    (a) (A

    B )

    (A

    B ) = A

    (b) AB (A B C ) = ( AB ) C

    3

  • 8/2/2019 Computing Fundamentals I Exercise Sheet 1 Answers

    4/4

    8. Suppose that X = {a, b}and Y = {c,d,e}. Write out in terms of an explicit listthe following sets:(a) P (X )

    (b) X Y (c) P (X X )

    Answer:(a) P (X ) = {, {a, b}, {a}, {b}}.

    (b) X Y = {(a, c ), (a, d ), (a, e ), (b, c), (b, d), (b, e)}.

    (c) P (X X ) = {, {(a, a ), (a, b), (b, a), (b, b)},{(a, a )}, {(a, b )}, {(b, a )}, {(b, b)},

    {(a, a ), (a, b )}, {(a, a ), (b, a )}, {(a, a ), (b, b)},{(a, b ), (b, a)}, {(a, b ), (b, b)}, {(b, a ), (b, b)},{(a, b ), (b, a), (b, b)}, {(a, a ), (b, a ), (b, b)},{(a, a ), (a, b ), (b, b)}, {(a, a ), (a, b ), (b, a)}}.

    4