Download presentation
Presentation is loading. Please wait.
Published byΑλάστωρ Κορομηλάς Modified over 5 years ago
1
The aim of education is to teach students how to think rather than what to think.
Sets The set is the fundamental discrete structure on which all other discrete structures are built.
2
Sets Definition. A Set is an unordered collection of objects, called elements or members of the set. Definition. The elements of a set are the objects in a set. Notation. Usually we denote sets with upper-case letters, elements with lower-case letters. The following notation is used to show set membership means that x is a member of the set A means that x is not a member of the set A.
3
Ways of Describing Sets
List the elements Give a verbal description “A is the set of all integers from 1 to 6, inclusive”
4
Another way to describe sets is to use set builder notation.
For instance, the set O of all odd positive integers less than 10 can be written as O = {x | x is an odd positive integer less than 10}, or, specifying the universe as the set of positive integers, as O = {x ∈ Z+| x is odd and x < 10}. We often use this type of notation to describe sets when it is impossible to list all the elements of the set. . 2/18/2019
5
Special Sets of Numbers
N = The set of natural numbers. = {0, 1, 2, 3, …}. Z = The set of integers. = { …, -3, -2, -1, 0, 1, 2, 3, …} Q = The set of rational numbers. ={x| x=p/q, where p and q are elements of Z and q ≠ 0 } H = The set of irrational numbers. R = The set of real numbers. C = The set of complex numbers.
6
Some Special Sets The Null Set or Empty Set. This is a set with no elements, often symbolized by The Universal Set. This is the set of all elements currently under consideration, and is often symbolized by U or
7
The Empty Set The empty set is a special set. It contains no elements. It is usually denoted as { } or . The empty set is always considered a subset of any set. Do not be confused by this question: Is this set {0} empty? It is not empty! It contains the element zero.
8
Universal Set and Subsets
The Universal Set denoted by U is the set of all possible elements used in a problem. When every element of one set is also an element of another set, we say the first set is a subset of the second set. Example A={1, 2, 3, 4, 5} and B={2, 3} We say that B is a subset of A. The notation we use is B A. Let S={1,2,3}, list all the subsets of S. The subsets of S are , {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}.
9
The singleton set A set with one element is called a singleton set. A common error is to confuse the empty set ∅ with the set {∅}, which is a singleton set. The single element of the set {∅} is the empty set itself! A useful analogy for remembering this difference is to think of folders in a computer file system. The empty set can be thought of as an empty folder and the set consisting of just the empty set can be thought of as a folder with exactly one folder inside, namely, the empty folder. 2/18/2019
10
Membership Relationships
Definition. Subset. “A is a subset of B” We say “A is a subset of B” if , i.e., all the members of A are also members of B. The notation for subset is very similar to the notation for “less than or equal to,” and means, in terms of the sets, “included in or equal to.”
11
Membership Relationships
Definition. Proper Subset. “ A is a proper subset of B” We say “A is a proper subset of B” if all the members of A are also members of B, but in addition there exists at least one element c such that but The notation for subset is very similar to the notation for “less than,” and means, in terms of the sets, “included in but not equal to.”
12
Difference between proper subset and subset
Simply: A PROPER subset is any subset of a set EXCEPT ITSELF and the NULL SET. So for instance, if you start with the set {green, eggs, ham, cheese}; {ham, cheese} is a proper subset, but {green, eggs, ham, cheese} is NOT a proper subset. 2/18/2019
13
Combining Sets – Set Union
“A union B” is the set of all elements that are in A, or B, or both. This is similar to the logical “or” operator.
14
Combining Sets – Set Intersection
“A intersection B” is the set of all elements that are in both A and B. This is similar to the logical “and”
15
Set Complement “A complement,” or “not A” is the set of all elements not in A. The complement operator is similar to the logical not, and is reflexive, that is,
16
Set Difference The set difference “A minus B” is the set of elements that are in A, with those that are in B subtracted out. Another way of putting it is, it is the set of elements that are in A, and not in B, so
17
Examples
18
Remark: Note that the concept of a datatype, or type, in computer science is built upon the concept of a set. In particular, a datatype or type is the name of a set, together with a set of operations that can be performed on objects from that set. For example, boolean is the name of the set {0, 1} together with operators on one or more elements of this set, such as AND, OR, and NOT. 2/18/2019
19
Venn Diagram: Example U
A set can be represented graphically using a Venn Diagram U x y B A z a C
20
Set Operators: Union Definition: The union of two sets A and B is the set that contains all elements in A, B, or both. We write: AB = { x | (a A) (b B) } U A B
21
Disjoint Sets Definition: Two sets are said to be disjoint if their intersection is the empty set: A B = U A B
22
Set Operators: Intersection
Definition: The intersection of two sets A and B is the set that contains all elements that are element of both A and B. We write: A B = { x | (a A) (b B) } U A B
23
Set Difference Definition: The difference of two sets A and B, denoted A\B ($\setminus$) or A−B, is the set containing those elements that are in A but not in B U A B
24
Set Complement Definition: The complement of a set A, denoted A ($\bar$), consists of all elements not in A. That is the difference of the universal set and A: U\A A= AC = {x | x A } U A A
25
Mutually Exclusive and Exhaustive Sets
Definition. We say that a group of sets is exhaustive of another set if their union is equal to that set. For example, if we say that A and B are exhaustive with respect to C. Definition. We say that two sets A and B are mutually exclusive if , that is, the sets have no elements in common.
26
Some Test Questions
27
Some Test Questions
28
Cardinal Number The Cardinal Number or cardinality of a set is the number of distinct elements in the set and is denoted by n(A) or |A| . Let A={2,4,6,8,10}, then n(A)=5. The Cardinal Number formula for the union of two sets is n(A U B)=n(A) + n(B) – n(A∩B). The Cardinal number formula for the complement of a set is n(A) + n(A’)=n(U).
29
Power Set (1) Definition: The power set of a set S, denoted P(S), is the set of all subsets of S. Examples Let A={a,b,c}, P(A)={,{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}} Let A={{a,b},c}, P(A)={,{{a,b}},{c},{{a,b},c}} Note: the empty set and the set itself are always elements of the power set.
30
Power Set (2) The power set is a fundamental combinatorial object useful when considering all possible combinations of elements of a set Fact: Let S be a set such that |S|=n, then |P(S)| = 2n
31
Computer Representation of Sets (1)
There really aren’t ways to represent infinite sets by a computer since a computer has a finite amount of memory If we assume that the universal set U is finite, then we can easily and effectively represent sets by bit vectors Specifically, we force an ordering on the objects, say: U={a1, a2,…,an} For a set AU, a bit vector can be defined as, for i=1,2,…,n bi=0 if ai A bi=1 if ai A
32
Assume that the universal set U is finite (and of reasonable size so that the number of elements of U is not larger than the memory size of the computer being used). First, specify an arbitrary ordering of the elements of U, for instance a1, a2, , an. Represent a subset A of U with the bit string of length n, where the ith bit in this string is 1 if ai belongs to A and is 0 if ai does not belong to A. 2/18/2019
33
example Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the ordering of elements of U has the elements in increasing order; that is, ai = i. What bit strings represent the subset of all odd integers in U, the subset of all even integers in U, and the subset of integers not exceeding 5 in U? 2/18/2019
34
Solution The bit string that represents the set of odd integers in U, namely, {1, 3, 5, 7, 9}, has a one bit in the first, third, fifth, seventh, and ninth positions, and a zero elsewhere. It is (We have split this bit string of length ten into blocks of length four for easy reading.) Similarly, we represent the subset of all even integers in U, namely, {2, 4, 6, 8, 10}, by the string The set of all integers in U that do not exceed 5, namely, {1, 2, 3, 4, 5}, is represented by the string 2/18/2019
35
Example 2 We have seen that the bit string for the set {1, 3, 5, 7, 9} (with universal set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) is What is the bit string for the complement of this set? Solution: The bit string for the complement of this set is obtained by replacing 0s with 1s and vice versa. This yields the string , which corresponds to the set {2, 4, 6, 8, 10}. 2/18/2019
36
Bit string representation for the union and intersection of two sets
To obtain the bit string for the union and intersection of two sets we perform bitwise Boolean operations on the bit strings representing the two sets. The bit in the ith position of the bit string of the union is 1 if either of the bits in the ith position in the two strings is 1 (or both are 1), and is 0 when both bits are 0. Hence, the bit string for the union is the bitwise OR of the bit strings for the two sets. The bit in the ith position of the bit string of the intersection is 1 when the bits in the corresponding position in the two strings are both 1, and is 0 when either of the two bits is 0 (or both are). Hence, the bit string for the intersection is the bitwise AND of the bit strings for the two sets. 2/18/2019
37
Example The bit strings for the sets {1, 2, 3, 4, 5} and {1, 3, 5, 7, 9} are and , respectively. Use bit strings to find the union and intersection of these sets. Solution: The bit string for the union of these sets is ∨ = , which corresponds to the set {1, 2, 3, 4, 5, 7, 9}. The bit string for the intersection of these sets is ∧ = , which corresponds to the set {1, 3, 5}. 2/18/2019
38
Computer Representation of Sets (2)
Examples Let U={0,1,2,3,4,5,6,7} and A={0,1,6,7} The bit vector representing A is: How is the empty set represented? How is U represented? Set operations become trivial when sets are represented by bit vectors Union is obtained by making the bit-wise OR Intersection is obtained by making the bit-wise AND
39
Computer Representation of Sets (3)
Let U={0,1,2,3,4,5,6,7}, A={0,1,6,7}, B={0,4,5} What is the bit-vector representation of B? Compute, bit-wise, the bit-vector representation of AB Compute, bit-wise, the bit-vector representation of AB What sets do these bit vectors represent?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.