Professional Documents
Culture Documents
Basics of Analysis of Algorithms
Basics of Analysis of Algorithms
BASICS OF ANALYSIS
OF ALGORITHMS
OUTLINES
2
Introduction
Factors that affect running time
Issues in Algorithm Analysis
Running Time computation technique
Worst case Running Time
Best case running time
Average case running time
Amortized Analysis
2
OUTLINES
3
3
INTRODUCTION
4
communication bandwidth.
4
FACTORS THAT AFFECT RUNNING TIME
5
5
FACTORS THAT AFFECT RUNNING TIME
6
3. Algorithm used
different algorithm require different running time for the
same problem under the same environment
6
FACTORS THAT AFFECT RUNNING TIME
7
7
ISSUES IN ALGORITHM ANALYSIS
8
8
ALGORITHM RUNNING TIME
9
9
WORST CASE RUNNING TIME
10
10
BEST CASE RUNNING TIME
11
11
AVERAGE CASE RUNNING TIME
12
Falls between the best case and the worst case extremes
It may not be simple to compute the average case for a given
algorithm
Average case computation can be made in three ways
Just by adding best case and worst case and divide by two
This is simple but not appropriate
By evaluating on a real environment with the representative data
By statistical means by randomly generating test data
12
AVERAGE CASE RUNNING TIME
13
Statistical approach
Established by considering possible inputs to an algorithm
Determining the number of steps performed by the algorithm
for each input
Adding the number of steps for all the inputs and dividing by
the number of inputs
13
AMORTIZED ANALYSIS
14
14
AMORTIZED ANALYSIS
15
15
RUNNING TIME COMPUTATION TECHNIQUE
16
17
RUNNING TIME COMPUTATION TECHNIQUE
18
18
RUNNING TIME COMPUTATION TECHNIQUE
19
19
RUNNING TIME COMPUTATION TECHNIQUE
20
20
RUNNING TIME COMPUTATION TECHNIQUE
21
21
RUNNING TIME COMPUTATION TECHNIQUE
22
22
RUNNING TIME COMPUTATION TECHNIQUE
23
23
RUNNING TIME COMPUTATION TECHNIQUE
24
The relational expressions might fail at the beginning (best case) or failed
when j become 0 (worst case)
24
RUNNING TIME COMPUTATION TECHNIQUE
25
25
RUNNING TIME COMPUTATION TECHNIQUE
26
Analysis
of a for loop
In general, a for loop translates to a summation
The index and bounds of the summation are the same as
the index and bounds of the for loop
for i = 1 to N do
sum = sum + i;
end for loop
26
RUNNING TIME COMPUTATION TECHNIQUE
27
27
RUNNING TIME COMPUTATION TECHNIQUE
28
Operating Environment
1.2.3. Complexity Analysis