Set
Set
operation.
SETS Representation
A set is a collection of objects.
A set is a group of “objects”
– People in a class: { Dibora, kasahun , chernet }
– Classes offered by a department: { CS 101, CS 202, … }
– Colors of a rainbow: { red, orange, yellow, green, blue,
purple }
– States of matter { solid, liquid, gas, plasma }
– States in the US: { Alabama, Alaska, Virginia, … }
– Sets can contain non-related elements: { 3, a, red, Virginia }
• Although a set can contain (almost)
anything, we will most often use sets of
numbers
–All positive numbers less than or
equal to 5: {1, 2, 3, 4, 5}
–A few selected real numbers:
–{ 2.1, π, 0, -6.32, e }
Set properties 1
• Order does not matter
–We often write them in order because
it is easier for humans to understand it
that way
–{1, 2, 3, 4, 5} is equivalent to {3, 5, 2,
4, 1}
• Sets are notated with curly brackets
Set properties 2
• Sets do not have duplicate elements
– Consider the set of vowels in the alphabet.