Sets

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

CHAPTER # 02,

BASIC
STRUCTURES:
SETS

Mah Noor Fatima


CS Lecturer
GCUF Sahiwal
A set is an unordered collection of distinct objects, called elements or
members of the set. A set is said to contain its elements. We write a ∈ A to
denote that a is an element of the set A. The notation a ∉ A denotes that a
is not an element of the set A.

• The set V of all vowels in the English alphabet can be written as V = {a, e, i, o, u}
• The set O of odd positive integers less than 10 can be expressed by O = {1, 3, 5, 7,
9}.
• The set of positive integers less than 100 can be denoted by {1, 2, 3, … , 99}
How to describe a set by saying what properties its
members have.
Intervals Notation
Types of Set
Finite Set
A set which contains a definite number of elements is called a finite set.

Example − S={ x | x∈N and 70>x>50}

Infinite Set
A set which contains infinite number of elements is called an infinite set.
Example − S={ x | x∈N and x>10}

Subset
A set X is a subset of set Y (Written as X⊆Y) if every element of X is an element of set Y.
Example 1 − Let, X={1,2,3,4,5,6} and Y={1,2}.
Here set Y is a subset of set X as all the elements of set Y is in set X. Hence, we can write
Y⊆X.
Example 2 − Let, X={1,2,3} and Y={1,2,3}.
Here set Y is a subset (Not a proper subset) of set X as all the elements of set Y is in set X.
Hence, we can write Y⊆X.
Proper Subset Types of Set
The term “proper subset” can be defined as “subset of but not equal to”.
A Set X is a proper subset of set Y (Written as X⊂Y) if every element of X
is an element of set Y and |X|<|Y|.
Example − Let, X={1,2,3,4,5,6} and Y={1,2}. Here set Y⊂X since all elements in Y
are contained in X too and X has at least one element is more than set Y.

Universal Set
It is a collection of all elements in a particular context or application. All the sets in that
context or application are essentially subsets of this universal set. Universal sets are
represented as U.
Example − We may define U as the set of all animals on earth. In this case, set of
all mammals is a subset of U, set of all fishes is a subset of U, set of all insects is a
subset of U, and so on.

Empty Set or Null Set


An empty set contains no elements. It is denoted by ∅. As the number of elements in an
empty set is finite, empty set is a finite set. The cardinality of empty set or null set is zero.
Example − S={x|x∈N and 7<x<8}=∅
Types of Set
Singleton Set or Unit Set
Singleton set or unit set contains only one element.
A singleton set is denoted by {s}.
Example − S={x|x∈N, 7<x<9} = {8}

Equivalent Set
If the cardinalities of two sets are same, they are called equivalent sets.
Example − If A={1,2,6} and B={16,17,22},
they are equivalent as cardinality of A is equal to the cardinality of B.
i.e. |A|=|B|=3

Equal Set
If two sets contain the same elements they are said to be equal.
Example − If A={1,2,6} and B={6,1,2}, they are equal as every
element of set A is an element of set B and every element of set B is
an element of set A.
Another look at Equality of Sets
Types of Set
Overlapping Set
Two sets that have at least one common element are called overlapping sets.
Example − Let, A={1,2,6} and B={6,12,42}.
There is a common element ‘6’, hence these sets are overlapping sets.

Disjoint Set
Two sets A and B are called disjoint sets if they do not have even one element in
common.
Therefore, disjoint sets have the following properties −
n(A∩B)=∅
n(A∪B)=n(A)+n(B)
Example − Let, A={1,2,6} and B={7,9,14}, there is not a single common
element, hence these sets are disjoint sets.
What is the power set of the set {0, 1, 2}?
Solution: The power set ({0, 1, 2}) is the set of all subsets of {0, 1, 2}.
Hence, Examples ({0, 1, 2}) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}.
Note that the empty set and the set itself are members of this set of subsets

Cartesian product of A = {1, 2} and B = {a, b, c}?


Solution: The Cartesian product A × B is;
A × B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}.

The cardinality of a finite set A, denoted by |A|, is the number of (distinct)


elements of A.
Examples: 1. |ø| = 0
2. Let S be the letters of the English alphabet. Then |S| = 26
3. |{1,2,3}| = 3
4. |{ø}| = 1
5. The set of integers is infinite.
Using Set Notation with Quantifiers

Truth Sets
and
Quantifiers
Set Operation Venn Diagrams
If sets A and B are represented as regions in the plane, relationships
between A and B can be represented by pictures, called Venn
diagrams, that were introduced by the British mathematician John
Venn in 1881.
Set Operation
Union of Sets: Union of Sets A and B is defined to be the set of all those elements which belong to A or B or
both and is denoted by A∪B.
A∪B = {x: x ∈ A or x ∈ B}
Example: Let A = {1, 2, 3}, B= {3, 4, 5, 6}
A∪B = {1, 2, 3, 4, 5, 6}.

|A ∪ B|=|A|+|B|−|A ∩ B|
Principle of inclusion–exclusion.

Intersection of Sets: Intersection of two sets A and B is the set of all those elements which belong to both
A and B and is denoted by A ∩ B.
A ∩ B = {x: x ∈ A and x ∈ B}
Example: Let A = {11, 12, 13}, B = {13, 14, 15}
A ∩ B = {13}.

Difference of Sets: The difference of two sets A and B is a set of all those elements which belongs to A but
do not belong to B and is denoted by A - B.
A - B = {x: x ∈ A and x ∉ B}
Example: Let A = {1, 2, 3, 4} and B = {3, 4, 5, 6}
then A - B = {3, 4} and B - A = {5, 6}
Set Operation
Complement of a Set: The Complement of a Set A is a set of all those elements of
the universal set which do not belong to A and is denoted by Ac.

Ac = U - A = {x: x ∈ U and x ∉ A} = {x: x ∉ A}


Example: Let U is the set of all natural numbers.
A = {1, 2, 3}
Ac = {all natural numbers except 1, 2, and 3}.

Symmetric Difference of Sets: The symmetric difference of two sets A and B is


the set containing all the elements that are in A or B but not in both and is denoted by A
⨁ B i.e.

A ⨁ B = (A ∪ B) - (A ∩ B)
Example: Let A = {a, b, c, d}
B = {a, b, l, m}
A ⨁ B = {c, d, l, m}
Set Identities Generalized Unions and Intersections
Methods of identity Proof
1. Prove that each set (side of the identity) is a subset of the other.
2. Use set builder notation and propositional logic.
3. Membership Tables:Verify that elements in the same combination of sets
always either belong or do not belong to the same side of the identity. Use 1
to indicate it is in the set and a 0 to indicate that it is not.

Proving Set
Identities
Proof of Second De Morgan Law
Set-Builder Notation: Second De Morgan Law
Use a membership table to show that A ∩ (B ∪ C) = (A ∩ B) ∪ (A
∩ C).
Generalized Unions and
Intersections
Computer Representation of Sets
There are various ways to represent sets using a computer. One method is to store the
elements of the set in an unordered fashion. However, if this is done, the operations of
computing the union, intersection, or difference of two sets would be time-consuming,
because each of these operations would require a large amount of searching for elements.
We will present a method for storing elements using an arbitrary ordering of the elements of
the universal set. This method of representing sets makes computing combinations of sets
easy.
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?

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 10 1010 1010.
(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 01 0101 0101.
The set of all integers in U that do not exceed 5, namely, {1, 2, 3, 4, 5}, is represented
by the string 11 1110 0000.

You might also like