SET • Set is a collection of well defined objects, called the elements of the set. • Set is represented by capital letters - A, B, … • Elements are represented by lower case letters – a, b, e, x, ……
5 different ways to describe a set 4. Describe a set by a recursive formula. 5. Describe a Set Based on Operation.
Example • Describe the set containing all the nonnegative integers less than or equal to 5.
Possible Solutions
Exercise
Possible Solutions • {1, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31} • {-4, 3} • {S, U, B, E, T}
SETS - Usage in CSE • A lot of programming languages use set listing (enumerations) for defining data types. • For example, in C++/Java : enum Colour { Red, Blue, Green } defines a data type for specifying colours for a display. • Some programming languages even have a set data type built in. For example, in Pascal : type Colours = Set Of [ Red, Blue, Green ] also defines a data type for specifying colours for a display.
SETS - Usage in CSE • In Java Programming language Sets have its implementation in various classes like Hash. Set, Tree. Set, Linked. Hash. Set.
Notice that if a set contains other sets, the contained sets do not have to have the same number of members. A set can contain other sets : { {a, b }, { c }, { a, c } } Sets which contain other sets is the underlying principle behind one of the most important concepts in Object Orientated programming : inheritance.
• In fact, set theory provides theoretical foundation underlying the type systems of every kind of programming language.