Professional Documents
Culture Documents
DR Nazir A. Zafar Advanced Algorithms Analysis and Design
DR Nazir A. Zafar Advanced Algorithms Analysis and Design
DR Nazir A. Zafar Advanced Algorithms Analysis and Design
and Design
By
(Fundamentals of Algorithms)
• Introduction to Algorithms
• Designing Techniques
• Algorithm is a Technology
• Model of Computation
• Even we have supercomputers, it requires algorithm
• Algorithms makes difference in users and modeler
• Some of the applications areas of algorithms
Management and manipulation of data
Electronic commerce
Manufacturing and other commercial settings
Shortest paths etc.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Today Covered
1. {x : Z | x2 = x x} = {0, 1}
2. {x : N | x 0 mod 2 x} = {0, 2, 4, . . . }
3. {x : N | x 1 mod 2 x} = {1, 3, 5, . . . }
4. {x : Z | x ≥ 0 x ≤ 6 x} = {0, 1, 2, 3, 4, 5, 6}
5. {x : Z | x ≥ 0 x ≤ 6 x2} = {0, 1, 4, . . ., 25, 36}
6. {x : N | x 1 mod 2 x3} = {1, 27, 125, . . . }
Membership Operator
• If an element e is a member of set S then it is denoted as
e S and read e is in S. Let S is sub-collection of X
X = a set
SX
Now
: X x P X Bool
(x, S) = = 1 if x is in S
0 if x is not in S
Subset:
If each element of A is also in B, then A is said to be
a subset of B, A B and B is superset of A, B A.
Intersection
: X x X X
(A, B) = = {x : X | x A and x B x}
Union
: X x X X
(A, B) = = {x : X | x A or x B x}
Set Difference
\ : X x X X
\ (A, B) = = {x : X | x A but x B x}
Lemma 1: if #X = m, #Y = n then
# (X Y) = 2m n
A relation R X X, is
• Reflexive:
(x, x) R, x X
• Symmetric:
(x, y) R (y, x) R, x, y X
• Transitive:
(x, y) R (y, z) R (x, z) R
• Equivalence:
If reflexive, symmetric and transitive
X f
b 1
Y
c 2
d 3
X f
b 1
Y
c 2
d 3
X Input1 f output1
Y
Input2 output2
Input3 output3
... ...
Inputn outputn
X Input1 f output1
Y
Input2 output2
... ...
Inputn outputn