1 / 23

Lecture 2 Introduction To Sets

Lecture 2 Introduction To Sets. CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine. Lecture Introduction. Reading Rosen - Section 2.1 Set Definition and Notation Set Description and Membership Power Set and Universal Set Venn Diagrams. Set Definition.

latham
Download Presentation

Lecture 2 Introduction To Sets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  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} CSCI 1900

  4. 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 Set Description Examples Good Not So Good CSCI 1900

  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 • Ø • { } CSCI 1900

  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 numbersW • 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 ? CSCI 1900

  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 } CSCI 1900

  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 notan 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+ CSCI 1900

  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} CSCI 1900

  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 CSCI 1900

  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} CSCI 1900

  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} CSCI 1900

  13. 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 ? Membership and Subset Exercise CSCI 1900

  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 CSCI 1900

  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  CSCI 1900

  16. Power Set Example • Given: S = {x,y,z} • P(S) = {, {x}, {y}, {z}, {x,y}, {y,z}, {x,z}, {x,y,z} } • Nota Bene • If there are n elements in a set S then there are elements in the power set P(S) CSCI 1900

  17. Set Size • The cardinalityof 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 CSCI 1900

  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 CSCI 1900

  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 CSCI 1900

  20. Venn Diagrams: Subsets U = Z S1 = Integers divisible by 2 S2 = Integers divisible by 4 • This shows that • S1  Z and S2 Z andS2  S1 • If x  S2 then x S1, if x  S1 then x Z, if x  S2 then x  Z CSCI 1900

  21. U = Z S1 = Integers divisible by 2 S3 = Integers divisible by 5 Venn Diagrams: Subsets 2 • This shows that S1 Z and S3 Z,ifx S1 then x Z, if x  S3 then x  Z, and there exists at least one element y such that • y Zand y S1and y S3 CSCI 1900

  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} CSCI 1900

  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 CSCI 1900

More Related