π The Universal Set
The universal set U contains all possible elements under discussion. All sets we work with are subsets of this set. Example: the set of vowels is a subset of all lowercase alphabet letters.
β Set Union (A βͺ B)
Union includes all elements from both sets, without duplicates. Example:
{1, 2, 3} βͺ {3, 4, 5} = {1, 2, 3, 4, 5}
β΄οΈ Set Intersection (A β© B)
Intersection includes only the elements common to both sets. Example:
{a, b} β© {a, c} = {a}
β Set Difference (A - B)
Elements in A but not in B. Example:
{a, b} - {a, c} = {b}
π Symmetric Difference (A β B)
Elements in either A or B but not both. Example:
{a, b} β {a, c} = {b, c}
π« Complement (Δ)
All elements in the universal set not in A. Example:
If U = {1,2,3,4,5}, A = {1,3,5}, then Δ = {2,4}
π¦ Sets and Tuples
A tuple is an ordered sequence of elements, written in parentheses like (1, 2, 3). Order and repetition matter in tuples. Sets are unordered and do not allow duplicates.
Examples:
(1,2) β (2,1) // tuples
{1,2} = {2,1} // sets
Tuple of sets: ({a, b}, {1, 2})
Set of tuples: { (1, a), (2, b) }
β Key takeaway
Set operations and tuples give you a precise language for describing collections and relationships. They appear in data structures, databases, programming languages and many other areas of computer science.