2. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
2
Learning Outcome
By the end of this presentation, students will
be able to:
Analyze Algorithm
Identify the resources for analysis
Understand experimental approach for
analysis
Understand the analytical approach for
analysis
3. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
3
Algorithm Analysis
After correction of an Algorithm the next
step is to determine the amount of resources
(complexity of algorithms).
This step is called algorithm analysis.
Two questions we always ask about
algorithm:
Does it work correctly?
How long does it take?
The second question is not so obvious.
4. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
4
The efficiency of an algorithm:
F (steps (time complexity), storage (space
complexity), Bandwidth (I/O complexity)).
Run-time analysis:
Theoretical classification that estimates
the increase in running time of an
algorithm as its input size increases.
5. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
5
Run-time efficiency is a topic of great
interest in computer science.
A program can take seconds, hours or even
years to finish executing, depending on
which algorithm it implements.
7. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
7
Algorithm Analysis
How can we say that one algorithm performs
better than another?
Quantify the resources required to execute:
Time
Memory
I/O / Bandwidth
8. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
8
Algorithm analysis is used to:
Estimate the running time, space, I/O.
Reduce the running time.
Framework to describe the running time.
Correction of Algorithm.
The relation of time of Algorithm with the
size of data.
9. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
9
Provides insight into designing efficient
Algorithms.
Determine the bottlenecks.
Develop efficient algorithm for a given
problem.
Make better use of hardware.
10. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
10
Model of Implementation
For the analysis, we assume:
A generic one-processor
RAM model f computation
Algorithms will be implemented as
computer programs.
In the RAM model, instructions are executed
one after another (no concurrent operations)
11. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
11
Running Time Calculation
The efficiency of an algorithm is estimated
by its performance.
The performance of an algorithm can be
measured by the time, space & bandwidth
requirement.
The time, space & bandwidth requirement of
an algorithm is called the computational
complexity of the algorithm.
12. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
12
The greater the amount of the time and space
required, the more complex is the algorithm.
Which measure is more important?
Normally we are concerned with the time rather
than space.
The reasons are that:
Firstly it becomes easier and cheaper to obtain
space.
Secondly techniques to achieve space efficiency
by spending more time are available.
13. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
13
Analysis Tools
Running time is a natural measure of
goodness, since time is a precious resource.
Computer solutions should run as fast as
possible.
The running time is affected by:
Hardware environment
Software environment
14. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
14
Measuring Running Time
Factors that affect running time:
Machine
Compiler
Algorithm
Input data
CPU used by other processes (Garbage
collection)
Therefore it is difficult to get precise
measurements.
15. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
15
The amount of time depends on the amount
of input.
T = f(input size)
The exact value of the function depends on:
Speed of the host machine,
The quality of the compiler,
The quality of programs.
16. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
16
Analyzing an algorithm, time is not really a
number of seconds but the number of
operations.
The number of operations is related to the
execution time, so we will use the word time
to describe an algorithm’s computational
complexity.
17. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
17
The Experimental Approach
The best way.
But, there are some reasons which reject the
use of this method:
We would like to eliminate the bad ones
early.
This method does not enable you to reason
about whether the efficiency can be
improved.
18. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
18
This method does not give you any insight
into how the program will perform if run
on different hardware or under different
conditions.
The effort involve program and testing.
May be one Algorithm is not better
written.
19. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
19
The Analytic Approach
In theoretical approach the time complexity is the
number of steps.
It characterizes running time as a function of the
input size.
It takes into account all possible inputs.
It allows us to evaluate the speed of an algorithm
independent of the hardware/software
environment.
22. Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
22
Exercises
Explain by example the analysis of Algorithm
What Resources are analyzed, which resource
is more important & why?
Explain the difference between Experimental
& analytical approach.