**Sets and Union **** Aptitude basics, practice questions, answers and explanations **

**Prepare for companies tests and interviews**

A set can be defined as a collection of things that are brought together because they obey a certain rule. These 'things' may be anything you like: numbers, people, shapes, cities, bits of text ..., literally anything. The key fact about the 'rule' they all obey is that it must be well-defined. In other words, it enables us to say for sure whether or not a given 'thing' belongs to the collection. If the 'things' we're talking about are English words, for example, a well-defined rule might be: '... has 5 or more letters'. A rule which is not well-defined (and therefore couldn't be used to define a set) might be: '... is hard to spell'

**Elements**

A 'thing' that belongs to a given set is called an element of that set.

For example: Henry VIII is an element of the set of Kings of England

**Notation**

Curly brackets {...... } are used to stand for the phrase 'the set of ...'. These braces can be used in various ways.

For example: We may list the elements of a set: { − 3, − 2, − 1,0,1,2,3}.

We may describe the elements of a set: { integers between − 3 and 3 inclusive}.

We may use an identifier (the letter x for example) to represent a typical element, a | symbol to stand for the phrase 'such that', and then the rule or rules that the identifier must obey:

{x | x is an integer and | x | < 4} or {x|x ? Z, |x| <4 }

The last way of writing a set - called set comprehension notation - can be generalized as:

x | P(x), where P(x) is a statement (technically a propositional function) about x and the set is the collection of all elements x for which P is true.

The symbol ? is used as follows:

? means 'is an element of ...'. For example: dog ? {quadrupeds}

? means 'is not an element of ...'. For example:

Washigton DC ? {European capital cities}

A set can be finite: {British citizens}or infinite: {7, 14, 21, 28, 35, …. }.

Sets will usually be denoted using upper case letters: A, B, ...

Elements will usually be denoted using lower case letters: x, y, ...

**Some Special Sets**

**1.Universal Set**

The set of all the 'things' currently under discussion is called the universal set (or sometimes, simply the universe). It is denoted by U. The universal set doesn’t contain everything in the whole universe. On the contrary, it restricts us to just those things that are relevant at a particular time. For example, if in a given situation we’re talking about numeric values – quantities, sizes, times, weights, or whatever – the universal set will be a suitable set of numbers (see below). In another context, the universal set may be {alphabetic characters} or {all living people}, etc.

**2.Empty set**

The set containing no elements at all is called the null set, or empty set. It is denoted by a pair of empty braces: { } or by the symbol f. It may seem odd to define a set that contains no elements. Bear in mind, however, that one may be looking for solutions to a problem where it isn't clear at the outset whether or not such solutions even exist. If it turns out that there isn't a solution, then the set of solutions is empty.

For example:

If U = {words in the English language} then {words with more than 50 letters}= f .

If U = {whole numbers} then {x|x2 = 10} = f .

Operations on the empty set

Operations performed on the empty set (as a set of things to be operated upon) can also be confusing. (Such operations are nullary operations.) For example, the sum of the elements of the empty set is zero, but the product of the elements of the empty set is one (see empty product). This may seem odd, since there are no elements of the empty set, so how could it matter whether they are added or multiplied (since “they” do not exist)? Ultimately, the results of these operations say more about the operation in question than about the empty set. For instance, notice that zero is the identity element for addition, and one is the identity element for multiplication.

**3.Equality**

Two sets A and B are said to be equal if and only if they have exactly the same elements. In this case, we simply write:

A = B

Note two further facts about equal sets:

The order in which elements are listed does not matter.

If an element is listed more than once, any repeat occurrences are ignored.

So, for example, the following sets are all equal:

{1, 2, 3} = {3, 2, 1} = {1, 1, 2, 3, 2, 2}

(You may wonder why one would ever come to write a set like {1, 1, 2, 3, 2, 2}. You may recall that when we defined the empty set we noted that there may be no solutions to a particular problem - hence the need for an empty set. Well, here we may be trying several different approaches to solving a problem, some of which in fact lead us to the same solution. When we come to consider the distinct solutions, however, any such repetitions would be ignored.)

**4.Subsets**

If all the elements of a set A are also elements of a set B, then we say that A is a subset of B, and we write: A ⊆ B

For example: If T = {2, 4, 6, 8, 10} and E = {even integers}, then T ⊆ E

If A = {alphanumeric characters} and P = {printable characters}, then A ⊆ P

If Q = {quadrilaterals} and F = {plane figures bounded by four straight lines}, then Q ⊆ F

Notice that A ⊆ B does not imply that B must necessarily contain extra elements that are not in A; the two sets could be equal – as indeed Q and F are above. However, if, in addition, B does contain at least one element that isn’t in A, then we say that A is a proper subset of B. In such a case we would write: A ⊂ B

In the examples above:

E contains 12, 14, ... , so T ⊂ E

P contains $, ;, &, ..., so A ⊂ P

But Q and F are just different ways of saying the same thing, so Q = F.

The use of ⊂ and ⊆ is clearly analogous to the use of < and ≤ when comparing two numbers.

Note: Every set is a subset of the universal set, and the empty set is a subset of every set.

**5.Disjoint**

Two sets are said to be disjoint if they have no elements in common.

For example: If A = {even numbers} and B = {1, 3, 5, 11, 19}, then A and B are disjoint.

**Operations on Sets**

**1.Intersection**

The intersection of two sets A and B, written A ∩ B, is the set of elements that are in A and in B.

(Note that in symbolic logic, a similar symbol,^, is used to connect two logical propositions with the AND operator.)

For example, if A = {1, 2, 3, 4} and B = {2, 4, 6, 8}, then A ∩ B = {2, 4}.

We can say, then, that we have combined two sets to form a third set using the operation of intersection.

**2.Union**

In a similar way we can define the union of two sets as follows:

The union of two sets A and B, written A ∪ B, is the set of elements that are in A or in B (or both).

(Again, in logic a similar symbol,V, is used to connect two propositions with the OR operator.)

So, for example, {1, 2, 3, 4} ∪ {2, 4, 6, 8} = {1, 2, 3, 4, 6, 8}.

You'll see, then, that in order to get into the intersection, an element must answer 'Yes' to both questions, whereas to get into the union, either answer may be 'Yes'.

The ∪ symbol looks like the first letter of 'Union' and like a cup that will hold a lot of items. The ∩ symbol looks like a spilled cup that won't hold a lot of items, or possibly the letter 'n', for intersection. Take care not to confuse the two.

**3.Difference**

The difference of two sets A and B (also known as the set-theoretic difference of A and B, or the relative complement of B in A) is the set of elements that are in A but not in B.

This is written A - B, or sometimes A \ B.

For example, if A = {1, 2, 3, 4} and B = {2, 4, 6, 8}, then A - B = {1, 3}.

**4.Complement**

The set of elements that are not in a set A is called the complement of A. It is written A′ (or sometimes AC, or Â). Clearly, this is the set of elements that answer 'No' to the question Are you in A?.

For example, if U = N and A = {odd numbers}, then A′ = {even numbers}.

Notice the spelling of the word complement: its literal meaning is 'a complementary item or items'; in other words, 'that which completes'. So if we already have the elements of A, the complement of A is the set that completes the universal set.

**5.Cardinality**

The cardinality of a finite set A, written | A | (sometimes #(A) or n(A)), is the number of (distinct) elements in A. So, for example:

If A = {lower case letters of the alphabet}, | A | = 26.

**Some special sets of numbers**

Several sets are used so often, they are given special symbols.

**1.The natural numbers**

The 'counting' numbers (or whole numbers) starting at 1, are called the natural numbers. This set is sometimes denoted by N. So N = {0, 1, 2, 3, ...}.

Note that, when we write this set by hand, we can't write in bold type so we write an N in blackboard bold font: N

**2.Integers**

All whole numbers, positive, negative and zero form the set of integers. It is sometimes denoted by Z. So Z = {..., -3, -2, -1, 0, 1, 2, 3, ...}

In blackboard bold, it looks like this: Z

**3.Real numbers**

If we expand the set of integers to include all decimal numbers, we form the set of real numbers. The set of reals is sometimes denoted by R.

A real number may have a finite number of digits after the decimal point (e.g. 3.625), or an infinite number of decimal digits. In the case of an infinite number of digits, these digits may:

recur; e.g. 8.127127127...

... or they may not recur; e.g. 3.141592653...

In blackboard bold: R

**4.Rational numbers**

Those real numbers whose decimal digits are finite in number, or which recur, are called rational numbers. The set of rationals is sometimes denoted by the letter Q.

A rational number can always be written as exact fraction p/q; where p and q are integers. If q equals 1, the fraction is just the integer p. Note that q may NOT equal zero as the value is then undefined.

For example: 0.5, -17, 2/17, 82.01, 3.282828... are all rational numbers.

In blackboard bold: Q

**5.Irrational numbers**

If a number can't be represented exactly by a fraction p/q, it is said to be irrational.

Examples include: √2, √3.