Professional Documents
Culture Documents
University of Sialkot
What is Algorithm?
2
Algorithm
is any well-defined computational procedure that takes
some value, or set of values, as input and produces
some value, or set of values, as output.
is thus a sequence of computational steps that transform
the input into the output.
is a tool for solving a well - specified computational
problem.
Any special method of solving a certain kind of
problem (Webster Dictionary)
Analysis of Algorithm
Tuesday, September 21, 2021
ALGORITHMICS
Analysis of Algorithm
Tuesday, September 21, 2021
Introduction
5
Analysis of Algorithm
Tuesday, September 21, 2021
Where We're Going
6
Correctness
Does the input/output relation match algorithm
requirement?
Amount of work done (Time complexity)
Basic operations to do task finite amount of time
Amount of space used
Memory used
Analysis of Algorithm
Tuesday, September 21, 2021
Which algorithm is better?
The algorithms are correct,
but which is the best?
Measure the running time
(number of operations
needed).
Measure the amount of
memory used.
Note that the running time
of the algorithms increase as
the size of the input
increases.
Running Time
80
Average case time is often 60
difficult to determine.
40
We focus on the worst case
20
running time.
0
Easier to analyze 1000 2000 3000 4000
Crucial to applications such as Input Size
games, finance and robotics
Tuesday, September
Analysis of Algorithm 10
21, 2021
Experimental Studies
Time (ms)
composition 5000
Analysis of Algorithm
Tuesday, September 21, 2021
Theoretical Analysis
13
Analysis
Tuesday, September 21, of Algorithm
2021
Asymptotic Analysis
14
thanks to www.tutorialspoint.com
Asymptotic Analysis (Continued…)
15
thanks to www.tutorialspoint.com
Omega Notation, Ω
18
thanks to www.tutorialspoint.com
Theta Notation, θ
19
thanks to www.tutorialspoint.com
Big-Oh Notation
20
Analysis of Algorithm
Tuesday, September 21, 2021
Theta Notation, θ
21
Analysis of Algorithm
Tuesday, September 21, 2021
Common Asymptotic Notations
28
constant − Ο(1)
logarithmic − Ο(log n)
linear − Ο(n)
n log n − Ο(n log n)
2
quadratic − Ο(n )
3
cubic − Ο(n )
Ο(1)
polynomial − n
Ο(n)
exponential − 2
Comparing Growth Rates
29
Graph of Various Algorithms
30
Graph of Various Algorithms
31
Example
32
C# (C Sharp)
PHP
CSS/HTML