Download presentation

Presentation is loading. Please wait.

Published bySavannah Tash Modified over 2 years ago

1
Lecture 2 Introduction To Sets CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine

2
CSCI 1900 Lecture 2 - 2 Lecture Introduction Reading –Rosen - Section 2.1 Set Definition and Notation Set Description and Membership Power Set and Universal Set Venn Diagrams

3
CSCI 1900 Lecture 2 - 3 Set Definition Set: any well-defined collection of objects –The objects are called set members or elements –Well-defined - membership can be verified with a Yes/No answer Three ways to describe a set –Describe in English S is a set containing the letters a through k, inclusively –Roster method - enumerate using { } ‘Curly Braces’ S = {a, b, c, d, e, f, g, h, i, j, k} –Set builder method ; Specify common properties of the members S = { x | x is a lower case letter between a and k, inclusively}

4
CSCI 1900 Lecture 2 - 4 Set Description Examples Star Wars films S = {car, cat, C ++, Java} {a,e,i,o,u,y} The 8 bit ASCII character set Good SciFi Films S = { 1, car, cat, 2.03, …} a,e,i,o,u & sometimes y The capital letters of the alphabet GoodNot So Good

5
CSCI 1900 Lecture 2 - 5 Finite Set Examples Coins –C = {Penney, Nickel, Dime, Quarter, Fifty ‑ Cent, Dollar} Data types –D = {Text, Integer, Real Number} A special set is the empty set, denoted by –Ø –{ }

6
CSCI 1900 Lecture 2 - 6 Infinite Set Examples The set of all integers Z –Z = { …, -3, - 2, -1, 0, 1, 2, 3, …} The set of positive Integers Z + (Counting numbers) – Z + = { 1, 2, 3, …} The set of whole numbers W – W = { 0, 1, 2, 3, …} The Real Numbers R –Any decimal number The Rational Numbers Q –Any number that can be written as a ratio of two integers Example of a number that is in R but not in Q ?

7
CSCI 1900 Lecture 2 - 7 Additional Set Description The set of even numbers E –E is the set containing … -8, -6, -4, -2, 0, 2, 4, 6, 8, … –E = any x that is 2 * some integer –E = Set of all x | x = 2*y where y is an integer –E ={ x | x = 2*y where y is an integer } –E = { x | x = 2*y where y is in Z } –E = { x | x = 2*y where y Z }

8
CSCI 1900 Lecture 2 - 8 Set Membership x is an element of A is written x A –Means that the object x is in the set A x is not an element of A is written x A Given: S={1, -5, 9} and Z + the positive Integers – 1 S 1 Z + – -5 S -5 Z + – 2 S 2 Z +

9
CSCI 1900 Lecture 2 - 9 Set Ordering and Duplicates Order of elements does not matter –{1, 6, 9} = {1, 9, 6} = {6, 9, 1} Repeated elements do not matter –{1, 1, 1, 1, 2, 3} = {1, 2, 3} = {1, 2, 2, 3}

10
CSCI 1900 Lecture 2 - 10 Set Equality Two sets are equal if and only if they have the same elements –S1 = {1, 6, 9} –S2 = {1, 9, 6} –S3 = {1, 6, 9, 6} S1 = S2 - same elements just reordered S2 = S3 - remember duplicates do not change the set Since S1= S2 and S2 = S3 then S1=S3

11
CSCI 1900 Lecture 2 - 11 Subsets A is a subset of B, if and only if every element of set A is an element of set B –Denoted A B Examples –{Kirk, Spock} {Kirk, Spock, Uhura} –{Kirk, Spock} {Kirk, Spock} For any set S, S S is always true –{Kirk, Sulu} {Kirk, Spock, Uhura}

12
CSCI 1900 Lecture 2 - 12 Proper Subsets If every element of set A is an element of set B, AND A≠B then A is a proper subset of B, denoted A B Examples –{1,2} {1,2,3} –{2} {1,2,3} –{3,3,3,1} {1,2,3} –{1,2,3} {1,2,3} But {1,2,3} {1,2,3} –{2,3,1} {1,2,3} But {2,3,1} {1,2,3}

13
CSCI 1900 Lecture 2 - 13 Membership and Subset Exercise Given: D = { 1, 2, {1}, {1,3}} Is 1 D ? Is 3 D ? Is 1 D? Is {1} D ? Is {2} D ? Is {1} D? Is {1} D? Is {3} D? Is { {1} } D ? Is { {1,2} } D ?

14
CSCI 1900 Lecture 2 - 14 Subsets and Equality Given: Two sets A and B –If you know that A B and B A then you can conclude that A = B –If A B then it must be true that B A

15
CSCI 1900 Lecture 2 - 15 Power Set The power set P of a set S is a set containing every possible unique subset of S –Written as P(S) P(S) always includes – S itself –The empty set

16
CSCI 1900 Lecture 2 - 16 Power Set Example

17
CSCI 1900 Lecture 2 - 17 Set Size The cardinality of set S, denoted |S|, is the number distinct elements of S. –if S = {1,3,4,1}, then |S|=3 –|{1,3,3,4,4,1}| = 3 –|{2, 3, {2}, 5} | = 4 –|{ 2, 3, {2,3}, 5, { 2,{2,5} } }| = 5 –|Z | = ∞ –|Ø| = 0 A set is finite if it contains exactly n elements –Otherwise the set is infinite

18
CSCI 1900 Lecture 2 - 18 Universal Set There is no largest set containing everything We will use a (different) Universal Set, U, for each discussion – It is the set of all possible elements of the type we want to discuss, for each particular problem For an example involving even and odd integers we might say U = Z

19
CSCI 1900 Lecture 2 - 19 Venn Diagrams –A graphic way to show sets and subsets, developed by John Venn in the 1880’s –A set is shown as a Circle or Ellipse, and the Universal set as a rectangle or square –This shows that S1 Z, and if x S1 then x Z U = Z S1 = Integers divisible by 2

20
CSCI 1900 Lecture 2 - 20 Venn Diagrams: Subsets U = Z S1 = Integers divisible by 2 This shows that S1 Z and S2 Z and S2 S1 If x S2 then x S1, if x S1 then x Z, if x S2 then x Z S2 = Integers divisible by 4

21
CSCI 1900 Lecture 2 - 21 Venn Diagrams: Subsets 2 U = Z S1 = Integers divisible by 2 S3 = Integers divisible by 5,, This shows that S1 Z and S3 Z, if x S1 then x Z, if x S3 then x Z, and there exists at least one element y such that y Z and y S1 and y S3

22
CSCI 1900 Lecture 2 - 22 Venn Diagram Exercise Draw a Venn Diagram representation for the following example: –U = { x | x W and x < 10 } –A= {1, 3, 5, 7, 9} –B = { 1, 5, 7} –C = {1, 5, 7, 8}

23
CSCI 1900 Lecture 2 - 23 Key Concepts Summary Definition of a set Ways of describing a set Power sets and the Universal set Set Cardinality Draw and interpret Venn Diagrams

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google