Professional Documents
Culture Documents
1.2
1.2
Unit 1 – Introduction
NAME OF PRESENTATION
S.No Topic Name
1 Company
Fundamentals of the Analysis of Algorithm EfficiencyName
}
Example 2
Example 3
Order of Growth
The order of growth of the running time of an
algorithms, gives a simple characterization of algorithms
efficiency.
We are more interested in the order of growth on the
number of times the basic operation is executed on the
input size of an algorithm.
Because, for smaller inputs, it is difficult to distinguish
efficient algorithms vs. inefficient ones.
Order of Growth
2. Analysis Framework
Time complexity:
Compilation Time: Time taken to compile an algorithm while compiling, it checks for syntax and semantics errors.
Run Time: Time taken to compile an algorithm program. It depends upon the number of instructions present in the
algorithm. We consider 1 unit for executing 1 instruction.
Space complexity:
Fixed amount of memory
Variable amount of memory
Sequential Search
Best-case, Average-case, Worst-case
Sequential Search
Best Case
k = 7, n = 5 [7,8,9,1,2]
Comparison = 1 time
Cbest(n) = 1
Worst Case
k=2, n=5 [7,8,9,1,2]
Comparison = 5 times – n times
Cworst(n) = n
Best-case, Average-case, Worst-case
Sequential Search
Average Case
k = 7, n = 5 [1,2,3,7,8]
P (0<=P<=1)
Cavg(n) = [1.p/n+2.p/n+….+i.p/n+….+n.p/n] + n.(1-p)
=p/n [1+2+….+n]+n(1-p)
p/n . N(n+1)/2 + n(1-p)
Success : p=1 n+1/2
Unsuccess : p=0 : n
Best-case, Average-case, Worst-case
(a)Best Case
- Shortest time that an algorithm will use for a given
problem to produce the desired result.
T(n)=Ω(f(n))
(b)Average Case
- Average time that an algorithm will use for a given
problem.
(c) Worst Case
- longest time that an algorithm will use (Size n
(input)) for a given problem to produce a desired results.
T(n)=O(f(n))
Asymptotic Analysis
Asymptotic Analysis