You are on page 1of 36

Unit 1 : FOUNDATIONS

Syllabus:
Sets relations equivalence relations
partial orders functions recursive functions
sequences induction principle structural
induction
recursive algorithms counting pigeonhole
principle
permutations and combinations recurrence
relations
SNSCE - CSE

Set
Definition: Set is a well
s defined collection of objects

SNSCE - CSE

Set
s

SNSCE - CSE

Set
s

SNSCE - CSE

Set
s

SNSCE - CSE

Set
s

SNSCE - CSE

Set
s

SNSCE - CSE

Set
s

SNSCE - CSE

Set
s

This n means the


number of elements
in the set

SNSCE - CSE

Relatio
Definition: Let A and B be sets. A binary relation
ns of AB.
from A to B is a subset
In other words, for a binary relation R we have
R AB. We use the notation aRb to denote that
(a, b)R and aRb to denote that (a, b)R.
Example: Let P be a set of people, C be a set of
cars, and D be the relation describing which
person drives which car(s).
P = {Carl, Suzanne, Peter, Carla},
C = {Mercedes, BMW, tricycle}
D = {(Carl, Mercedes), (Suzanne, Mercedes),
(Suzanne, BMW), (Peter, tricycle)}
This means that Carl drives a Mercedes, Suzanne
drives a Mercedes and a BMW, Peter drives a
tricycle, and Carla does not drive any of these
vehicles.
SNSCE - CSE

10

Relatio
ns

SNSCE - CSE

11

Relatio
ns

SNSCE - CSE

12

Equivalence
Equivalence
relations are used to relate
Relations
objects that are similar in some way.

Definition: A relation on a set A is called an


equivalence relation if it is reflexive,
symmetric, and transitive.
Two elements that are related by an
equivalence relation R are called
equivalent.

SNSCE - CSE

13

Partial
Orders
A partial order
is a binary relation "" over a
set P which is reflexive, antisymmetric, and
transitive, i.e., which satisfies for all a, b, and c
in P:
a a (reflexivity);
if a b and b a then a = b (antisymmetry);
if a b and b c then a c (transitivity).
In other words, a partial order is an
antisymmetric preorder.
SNSCE - CSE

14

Function
s

SNSCE - CSE

15

Identity
function
A function f from a set A
to the same set A stating that
f(x) = x for all elements of x
in the set A.
Identity function is one
one and onto also.
It is a bijective mapping
from a set into it self.
SNSCE - CSE

16

One one
function
A function f from a set A
to set B such that for any
element of set B there exists
only one preimage in set A.
If f(a) = f(b) then a = b
for all elements of a,b in set
A.
It is also called as
injective or some times 1 1.
SNSCE - CSE

17

Onto
A function
function from a set A to
set B such that for all
elements of set B there exists
at least
one element in set B such
that f(a) = b.
It is also called as
surjective mapping.
Here f(A) = B.
All images are have
SNSCE - CSE

18

One to one
A function from a set A to set
function

B with the two properties one one


and onto.
It is also called as 1to1 or
some times bijective mapping
n(A) = n(B)
i. e. both the sets have same
number of elements.
one element to one image and
one image is for one element.
SNSCE - CSE

19

Step
function
A function
f from real

numbers set to integers set


stating that
f(x) = y where y-1<x<=y
for all real numbers x.
where y is an integer.
Examples are floor function or
ceiling function.
SNSCE - CSE

20

Absolute function
A function from real numbers set
to real numbers set stating that
x if x is > 0
f(x) =
-x if x is < 0
0 if x is = 0

SNSCE - CSE

21

Recursive
A recursive function is an equation that
Functions
recursively
defines a sequence, once one or
more initial terms are given: each further term of
the sequence is defined as a function of the
preceding terms.
The term difference equation sometimes
(and for the purposes of this article) refers to a
specific type of recurrence relation. However,
"difference equation" is frequently used to refer
Example: We obtain the sequence of Fibonacci numbers which
to
any recurrence relation.
begins:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
It can be solved by methods described below yielding the closed-form
expression which involve powers of the two roots of the characteristic
polynomial t2 = t + 1; the generating function of the sequence is the
rational function

SNSCE - CSE

22

Sequenc
A sequence
esis an ordered list. Like a set, it

contains members (also called elements, or


terms). The number of ordered elements (possibly
infinite) is called the length of the sequence.
Unlike a set, order matters, and exactly the
same elements can appear multiple times at
different positions in the sequence. Most precisely,
a sequence can be defined as a function whose
domain is a countable totally ordered set, such as
the natural numbers.
For example, (M, A, R, Y) is a sequence of
letters with the letter 'M' first and 'Y' last. This
sequence differs from (A, R, M, Y). Also, the
sequence (1, 1, 2, 3, 5, 8), which contains the
number 1 at two different positions, is a valid
23
SNSCE - CSE
sequence.

Induction
Principle
Mathematical
induction

is a method of
mathematical proof typically used to establish a
given statement for all natural numbers.
It is done in two steps.
The first step, known as the base case, is to
prove the given statement for the first natural
number.
The second step, known as the inductive
step, is to prove that the given statement for any
one natural number implies the given statement
for the next natural number.
From these two steps, mathematical
induction is the rule from which we infer that the
given statement is established for all natural
numbers.
SNSCE - CSE

24

Structural
Structural induction is a proof method that is used in
Induction
mathematical
logic (e.g., in the proof of o' theorem), computer

science, graph theory, and some other mathematical fields.


It is a generalization of mathematical induction over natural
numbers, and can be further generalized to arbitrary Noetherian
induction. Structural recursion is a recursion method bearing the
same relationship to structural induction as ordinary recursion bears
to ordinary mathematical induction.
Structural induction is used to prove that some proposition
P(x) holds for all x of some sort of recursively defined structure such
as lists or trees.
A well-founded partial order is defined on the structures
("sublist" for lists and "subtree" for trees).
The structural induction proof is a proof that the proposition
holds for all the minimal structures, and that if it holds for the
immediate substructures of a certain structure S, then it must hold
for S also. (Formally speaking, this then satisfies the premises of an
axiom of well-founded induction, which asserts that these two
conditions are sufficient for the proposition to hold for all x.)
SNSCE - CSE

25

Recursive
Algorithms
The Nature of Recursion Algorithms
Problems that lend themselves to a recursive solution have the
following characteristics: One or more simple cases of the problem
(called stopping cases) have a simple, non-recursive solution.
For the other cases, there is a process (using recursion) for substituting
one or more reduced cases of the problem that are closer to a stopping
case.
Eventually the problem can be reduced to stopping cases only, all of
which are relatively easy to solve.
if (the stopping case is
reached)
{
Solve it
}
else
{
Reduce the problem
using recursion
}

SNSCE - CSE

26

Recursive
To Algorithms
find N!: If N = 1 then N!

1.
N! = N x (N - 1)!

= 1; Otherwise

2. The Fibonacci sequence is defined below.


Fib1 is 1. Fib2 is 1. Fibn is Fibn-2 + Fibn-1,
for n > 2.

3.

GCD(M, N) is N if N <= M and N divides M.


GCD(M, N) is GCD(N, M) if M < N.
GCD(M, N) is GCD(N, remainder of M divided
by N) otherwise.
SNSCE - CSE

27

Counting

Combinatorics is a branch of mathematics concerning


the study of finite or countable discrete structures.
Aspects of combinatorics include counting the
structures of a given kind and size (enumerative
combinatorics), deciding when certain criteria can be met,
and constructing and analyzing objects meeting the criteria
(as in combinatorial designs and matroid theory), finding
"largest", "smallest", or "optimal" objects (extremal
combinatorics and combinatorial optimization), and studying
combinatorial structures arising in an algebraic context, or
applying algebraic techniques to combinatorial problems
(algebraic
combinatorics).
Counting
is the action of finding the number of elements of a
finite set of objects. The traditional way of counting consists of
continually increasing a (mental or spoken) counter by a unit for
every element of the set, in some order, while marking (or
displacing) those elements to avoid visiting the same element more
than once, until no unmarked elements are left; if the counter was
set to one after the first object, the value after visiting the final
object gives the desired number of elements. The related term
enumeration refers to uniquely identifying the elements of a finite
(combinatorial) set or infinite
set
by assigning a number to each
28
SNSCE
- CSE
element.

Pigeonhole
Pigeonhole principle : If n items are put into m
Principle
pigeonholes
with n > m, then at least one
pigeonhole must contain more than one item. This
theorem is exemplified in real-life by truisms like
"there must be at least two left gloves or two right
gloves in a group of three gloves".

It is an example of a
counting argument, and
despite seeming intuitive
it can be used to demonstrate
possibly unexpected results;
for example, that two people in
London have the same
number of hairs on their heads
SNSCE - CSE

29

Permutations and
Combinations
Permutation means to the act of permuting
(rearranging) objects or values. Informally, a
permutation of a set of objects is an arrangement of
those objects into a particular order.
example, there are six permutations of the set
{1,2,3}, namely (1,2,3), (1,3,2), (2,1,3), (2,3,1),
(3,1,2), and (3,2,1).
The number of permutations of n distinct
objects is "n factorial" usually written as "n!", which
means the product of all positive integers less than or
equal to n.
SNSCE - CSE

30

Permutations and
Combinations
A permutation of a set S of objects is an ordered
arrangement of these objects.
The number of r-permutations of a set with n
elements is denoted by P n r
Example:
How many permutations of the letter JKLMNOPQ contain
the string JKL?
Since the letter JKL must occur in a block, we must consider
six objects namely JKL as one block and M,N,O,P,Q. the six
objects can occur in any order and there are 6! = 720
permutations of the letters JKLMNOPQ in which JKL occurs
as a block
SNSCE - CSE

31

Permutations and
Combinatio
Combinations
ns

Def:An r-combination of elements of a


set S is simply a subset T of S with r
members.

Combinations with repetitions:


There are C(n+r-1, r) r-combinations f
set with n elements when repetition of ele
is allowed.
SNSCE - CSE

32

Permutations and
Combination is a way of selecting several
Combinations
things
out of a larger group, where (unlike
permutations) order does not matter. In smaller
cases it is possible to count the number of
combinations.
For example given three fruits, say an apple,
an orange and a pear, there are three combinations
of two that can be drawn from this set: an apple and
a pear; an apple and an orange; or a pear and an
orange.
More formally a k-combination of a set S is a
subset of k distinct elements of S. If the set has n
elements the number of k-combinations is equal to
the binomial coefficient
SNSCE - CSE

33

Recurrence
Relations

Recurrence relation is an equation that


recursively defines a sequence, once one or more
initial terms are given: each further term of the
sequence is defined as a function of the preceding
terms.

The Fibonacci numbers are the archetype of


a linear, homogeneous recurrence relation with
constant coefficients (see below). They are defined
using the linear recurrence relation

SNSCE - CSE

34

Recurrence
Recurrence relations are having
Relations
fundamental
importance in Analysis of
Algorithms. If an algorithm is designed so that
it will break a problem into smaller sub
problems, its running time is described by a
recurrence relation.
A simple example is the time an
algorithm takes to search an element in an
ordered vector with n elements, in the worst
case.
A naive algorithm will search from left to
right, one element at a time. The worst
possible scenario is when the required element
is the last, so theSNSCE
number
of comparisons is n.
- CSE

35

Recurrence
A better algorithm is called binary search. It
Relations
will first
check if the element is at the middle of
the vector.

If not, then it will check if the middle


element is greater or lesser than the seeked
element. At this point, half of the vector can be
discarded, and the algorithm can be run again on
the other half.
The number of comparisons will be given by
which will be close to

SNSCE - CSE

36

You might also like