Presentation is loading. Please wait.

Presentation is loading. Please wait.

Terms Set S Set membership x  S Cardinality | S |

Similar presentations


Presentation on theme: "Terms Set S Set membership x  S Cardinality | S |"— Presentation transcript:

1

2 Terms Set S Set membership x  S Cardinality | S |
Cartesian product R x S Subset R  S

3 Set an unordered collection of objects which are typically referred to as elements or members

4 The set of blue bricks that can be created in Bricklayer at levels 1 and 2.

5 The set of 2x2 bricks that can be created in Bricklayer at levels 1 and 2.

6 put2D_1x1_BLUE put2D_1x1_YELLOW put2D_1x1_GREEN put2D_1x1_BLACK put2D_1x1_RED put2D_1x1_WHITE put2D_1x1_GRAY The set of all function names that can create 1x1 bricks in Bricklayer at levels 1 and 2.

7 (0,0) (0,5) (5,0) (5,5) (10,0) (0,10) (10,10) (10,5) (5,10) The set of all coordinates whose values are multiples of 5 that belong to the coordinate space created by the Bricklayer function call build2D(11,11).

8 1x1 2x1 1x2 2x2 2x3 2x4 3x2 4x2 The set of all brick shapes available in Bricklayer at levels 1 and 2.

9 1 1 + 1 3 + 1 2 + 6 7 + 2 1 + 3 4 + 4 7 2 3 8 A set (not “the” set) of arithmetic expressions including integers and some integer additions.

10 When limiting our notation to just symbols, a set is typically denoted as a list of element symbols enclosed in curly braces. For example, the set consisting of the integers 1, 2, and 3 could be written as follows. { 1, 2, 3 } or { 2, 1, 3 } or etc. Note that, in a set, the order in which elements are listed is irrelevant. The set consisting of the integers one, two, and three could be written as follows. { one, two, three }

11 Set membership The primary operation on a set is membership. Given a set S and an element e we want to know whether  "e is a member of S".

12 is in

13 The formal way of asking whether e is a member of S is as follows.
e ∈ S The expression shown above contains an element e, a set S, and the symbol ∈ which denotes the set membership operator. For the sets that we are (primarily) interested in the answer to this membership question will be either true or false.

14 Set Expression Result {1, 2, 3} 1 ∈ {1,2,3} true 4 ∈ {1,2,3} false two ∈ {1,2,3} ?

15 Sets are very powerful Any problem can be restated in terms of set membership. Example: Is a prime number? Does belong to the set of prime numbers?

16 It is interesting to note that there exist sets for which the answer to a membership question can be "don't know“! These kinds of sets can be encountered when writing code.

17 cardinality The cardinality of a set is the number of elements the set contains.

18 Examples Let S denote an arbitrary set.
The expression |S| denotes the cardinality of S. if S = { 5, 10, 15 } then |S| = 3 if S = { a, b, c, d, e } then |S| = 5

19 Let S denote the set shown above.

20 put2D_1x1_BLUE put2D_1x1_YELLOW put2D_1x1_GREEN put2D_1x1_BLACK put2D_1x1_RED put2D_1x1_WHITE put2D_1x1_GRAY Let S denote the set shown above. |S| = 7

21 (0,0) (0,5) (5,0) (5,5) (10,0) (0,10) (10,10) (10,5) (5,10) Let S denote the set shown above. |S| = 9

22 Cartesian Product The Cartesian product of the sets R and S is written R x S and is the set of all possible elements of the form (r,s) where r  R and s  S.

23 x 1 3 1 3 2 2 1 2 3 ( 0, 0 ) ( 0, 1 ) ( 0, 2 ) ( 0, 3 ) ( 1, 0 ) ( 1, 1 ) ( 1, 2 ) ( 1, 3 ) ( 2, 0 ) ( 2, 1 ) ( 2, 2 ) ( 2, 3 ) ( 3, 0 ) ( 3, 1 ) ( 3, 2 ) ( 3, 3 )

24 x 2x1 RED 3x2 2x2 WHITE BLUE 1x1 RED WHITE BLUE 1x1 ( 1x1, RED )
( 1x1, BLUE ) 2x1 ( 2x1, RED ) ( 2x1, WHITE ) ( 2x1, BLUE ) 2x2 ( 2x2, RED ) ( 2x2, WHITE ) ( 2x2, BLUE ) 3x2 ( 3x2, RED ) ( 3x2, WHITE ) ( 3x2, BLUE )

25 Subset A set R is a subset of a set S if every element in R is also an element in S

26 Notation The expression R  S is an expression whose value is true if R is a subset of S and whose value is false otherwise. { 1 }  { 1, 2, 3 } is true { 1, 3 }  { 1, 2, 3 } is true { 4 }  { 1, 2, 3 } is false If |R| > |S| then R is not a subset of S

27 The set consisting of a 2x1 and 3x2 blue brick is a subset of the set of blue bricks that can be created in Bricklayer at levels 1 and 2.

28 The set of blue bricks, that can be created in Bricklayer at levels 1 and 2, whose shapes are NOT equal to 2x1 or 3x2 is a subset of the set of blue bricks that can be created in Bricklayer at levels 1 and 2.

29 1 7 2 3 8 1 1 + 1 3 + 1 2 + 6 7 + 2 1 + 3 4 + 4 7 2 3 8 The subset of a set of arithmetic expressions consisting of all (integer) values!

30  The set of all defined integer The set of all integers.
arithmetic expressions. Both sets contain an infinite number of elements. Elements in the set of arithmetic expressions can be simplified through computation!


Download ppt "Terms Set S Set membership x  S Cardinality | S |"

Similar presentations


Ads by Google