ADA Module1 Part2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

1.

4 ASYMPTOTIC NOTATIONS
The efficiency analysis framework concentrates on the order of growth of an
algorithm‘s basic operation count as the principal indicator of the algorithm‘s efficiency.
To compare and rank such orders of growth, computer scientists use three
notations: O (big oh), Ω(big omega), and Θ (big theta).
Informal Introduction
Informally, O(g(n)) is the set of all functions with a lower or same order of
growth as g(n) (to within a constant multiple, as n goes to infinity). Thus, to give a
few examples, the following assertions are all true:

Indeed, the first two functions are linear and hence have a lower order of growth than
g(n)=
n2, while the last one is quadratic and hence has the same order of growth as n2 . On the
other hand,

Indeed, the functions n3 and 0.00001n3 are both cubic and have higher order growth than
4
n2 and so has the fourth-degree polynomial n + n + 1.
The second notation, Ω (g(n)), stands for the set of all functions with a higher or same
order of growth as g(n) (to within a constant multiple, as n goes to infinity).

Finally, Θ (g(n)) is the set of all functions that have the same order of growth as g(n).

1
The definition is illustrated in the following figure

2
Example:

The definition is illustrated in the following figure.

Example:

3
4
For example , we can check whether an array has identical elements by means of the two
part algorithm : first part sort the array by applying sorting algorithm and second part scan
the sorted array to check its consecutive elements for equality. Here , if sorting algorithm
in first part of algorithm makes no more than ½ n(n-1) comparisons(O(n 2)) and second part
of algorithm makes no more than n-1 comparisons (O(n)) then the efficiency of entire
algorithm will be in O(max{n2,n})=O(n2).

Using limits for comparing orders of growth:


A much more convenient method for comparing orders of growth is by computing the limit
of ratio of two functions. The 3 principal cases are given by,

Here the value of c>0.


Note that first two cases mean t(n)∈O(g(n)) , the last two cases mean t(n) ∈ Ω(g(n)) and
the second case means t(n)∈Θ (g(n)).
The basic efficiency classes

5
Note:

6
1.5 Mathematical Analysis of Non Recursive Algorithms

7
8
9
10
11
12

You might also like