2. Analysis of Algorithm
Analysis of algorithms is usually
used in a narrower technical sense
to mean an investigation of an
algorithms efficiency with respect
to two resources.
Running time
Memory space
3. Runtime Analysis
Run-time analysis is a theoretical classification that
estimates and anticipates the increase in running time
(or run-time) of an algorithm as its input size (usually
denoted as n) increases.
Orders of growth
Empirical orders of growth
Evaluating run-time complexity
Shortcomings of empirical metrics
5. An algorithm is said to be asymptotically optimal
if, roughly speaking, for large input it performs at
worst a constant factors were than the best
possible algorithm.
A Sequence of an algorithm being asymptotically
optimal is that, for large enough input, no
algorithm can outperform it by more than a fixed
constants factors.
Approches
1. Theoretical analysis
2. Empirical analysis
6. Measuring an input size
Time efficiency is analyzed by determining the
number of repetitions of the basic operation as a
function of input size
Influenced by the data representation, e.g. matrix
Influenced by the operations of the algorithm, e.g.
spell-checker
Influenced by the properties of the objects in the
problem, e.g. checking if a given integer is a prime
number.
7. Unit for measuring running time
Using Standard unit of time measurement a
second, a millisecond and the running time
of a program implementing the algorithm.
Basic operation:
Applied to all input items in order to carry
out the algorithm.
Contributes most towards the running time
of the algorithm.
8. An important applications. Let c op be the
time of execution algorithms basic operation
on particular computer and let C(n) be the
number times this operation needs to be
executed for this algorithm.
T(n): running time
c op : execution time for basic operation
C(n) : number of times basic operation is executed
Then we have:
T(n) ≈ c op C(n)
9. Types of formulas count for basic operations
Exact formula e.g., C(n) = n(n-1)/2
Formula indicating order of growth with
specific multiplicative constant e.g. C(n) ≈
0.5 n2
Formula indicating order of growth with
unknown multiplicative constant
e.g., C(n) ≈ cn2
Example: Let C(n) = 3n(n-1) 3n2