Asymptotic Analysis
Introduction:
If you want to analyze two algorithms how you
will measure them-
The simplest way to do it is to implement both
the algorithms run them on some machine and check which one is faster. But
there are so some problems associated with this approach:
- For
some input algorithm A may perform well and for some input algorithm
B may perform well.
- For
some input algorithm A, is performing good on machine X
but for the same input on machine Y algorithm B is
doing good
All such problems can be handled using the
asymptotic notation as in asymptotic notation the performance of the algorithm is
measured in terms of input size. How the performance of algorithms grows as the
input size grows. The machine-dependent constants can always be ignored after a
certain value of input size.
Does it always work?
Asymptotic notation does not do good always for
example
- . Two
algorithms with the same growth with different machine constants cannot be compared
as in asymptotic notation we ignore the constants (0.2nlogn and 1000nlogn)
- .
In the asymptotic analysis, we analyze the algorithms for large input size, it might
possible that such large inputs are never given to your algorithm which is asymptotically slower. So, you might be discarding an algorithm that fits well
for your situation but is asymptotically slower.
The main idea of asymptotic analysis is to
measure the performance of an algorithm that does not depend upon the machine-dependent
constant, and doesn’t require algorithms to be implemented, and time taken by
programs to be compared.
Comments
Post a Comment