0% found this document useful (0 votes)
15 views21 pages

Class2 Asymptotic

The document discusses asymptotic notation, which categorizes algorithms based on their time complexity, including types such as Big O, Big Omega, and Big Theta notations. It highlights the importance of asymptotic analysis for algorithm efficiency, comparison, and design, while also addressing its advantages and disadvantages. Additionally, it outlines properties of asymptotic notations and provides examples to illustrate their application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views21 pages

Class2 Asymptotic

The document discusses asymptotic notation, which categorizes algorithms based on their time complexity, including types such as Big O, Big Omega, and Big Theta notations. It highlights the importance of asymptotic analysis for algorithm efficiency, comparison, and design, while also addressing its advantages and disadvantages. Additionally, it outlines properties of asymptotic notations and provides examples to illustrate their application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Asymptotic Notations

Dr J P Patra
Associate Professor
Computer Science & Engineering
UTD, CSVTU, Bhilai

1
Outline:
• What is Asymptotic Notation?

• Why Asymptotic Notation is important ?

• Types of Asymptotic Notations

• Properties of Asymptotic Notations

• Advantages and Disadvantages of Asymptotic Notations

2
What is Asymptotic Notation?
• Asymptotic notation is used to categorize algorithms into
complexity classes, such as polynomial time (P), exponential
time (EXP), or logarithmic space (L).
Or

• Asymptotic notations are mathematical tools to represent the


time complexity of algorithms for asymptotic analysis.

3
Why Asymptotic Notation is important?
Algorithm Analysis: Asymptotic notation is crucial for analyzing algorithms and
understanding their efficiency. This analysis is essential for selecting the most
efficient algorithm for a given problem.

Factors which influence Analysis

• Number of steps present in an Algorithm

• Different Operators used in an Algorithm

• Processing Speed of the Machine

• Input sequence provided by the User


4
• Algorithm Comparison: Asymptotic notation provides a
standardized way to compare the performance of different algorithms
without being influenced by specific hardware or software details.

• Predicting Performance: Asymptotic notation allows us to predict


how an algorithm will perform as input sizes become very large.

• Algorithm Design: Asymptotic analysis helps algorithm designers


make informed decisions about trade-offs between efficiency and
functionality.

5
Types of Asymptotic Notations
• Big O Notation (O)

• Big Omega Notation (Ω)

• Big Theta Notation (Θ)

• Little o Notation (o)

• Little Omega Notation (ω)

6
Big O Notation (O)
Big O notation represents the upper bound of the running time of
an algorithm. Thus, it provides the worst case complexity of an
algorithm.
Definition :
The function f(n) is Big O of g(n) written as f(n)= O(g(n)), if there
exist two positive constants C and n0 such that f(n) ≤ C.g(n) , for
all n ≥ n0

7
Example: Prove that f(n)=2n2+3n+5 = O(n2)
or

Calculate the Upper Limit of the above Function.

Solution: As the above problem deals with Big O Notation we must have to
satisfy the condition f(n) ≤ cg(n) for n ≥ n0

So, we write 2n2+3n+5 ≤ 2n2+3n+n (When n ≥ 5 , i.e n0 =5)


=>2n2+3n+5 ≤ 2n2+4n
8
Further we can write this as
=>2n2+4n ≤ 2n2+ n2 (When n2 ≥ 4n, i.e n ≥ 4, i.e n0 =4)
=>2n2+4n ≤ 3n2
So, we can see that the value of f(n)= 2n2+3n+5 will always be less
than or equal to g(n)= n2 when we start the value of n with 4 or 5.
Hence 2n2+3n+5 = O(n2) is true at n=4 or n=5.
For this problem
2n2+3n+5 = O(n3) is true
2n2+3n+5 = O(n4) is true
and 2n2+3n+5 = O(2n) is also true.
9
Big Omega Notation (Ω)
Omega notation represents the lower bound of the running time
of an algorithm. Thus, it provides the best case complexity of an
algorithm.
Definition :
The function f(n) is Big Omega of g(n) written as f(n)= Ω (g(n)), if
there exist two positive constants C and n0 such that f(n) ≥ C.g(n)
,for all n ≥ n0

10
Example:
(i) f(n)=2n2+3n+5 = Ω (n2) is True
(ii) f(n)=2n2+3n+5 = Ω (n) is True
(iii) f(n)=2n2+3n+5 = Ω (√n) is True
(iv) f(n)=2n2+3n+5 = Ω (logn) is True

11
Big Theta Notation (Θ)
Theta notation encloses the function from above and below.
Since it represents the upper and the lower bound of the running
time of an algorithm, it is used for analyzing the average-case
complexity of an algorithm.

Definition :
The function f(n) is Big Theta of g(n) written as f(n)= ϴ (g(n)), if
there exist three positive constants C1 ,C2 and n0 such that C1 *
g(n) ≤ f(n) ≤ C2 * g(n), for all n ≥ n0

12
Big O Notation

Omega Notation

13
Example:
(i) f(n)=2n+5 = ϴ (n) is True
then

(ii) f(n)=2n+5 = ϴ(n2) will be False


also

(iii) f(n)=2n+5 = ϴ(√n) will be False

14
Properties of Asymptotic Notations
General Properties:

If f(n) is O(g(n)) then a*f(n) is also O(g(n)), where a is a constant.

Example:
f(n) = 2n²+5 is O(n²)
then, 7*f(n) = 7(2n²+5) = 14n²+35 is also O(n²).

Note: Similarly, this property satisfies both Θ and Ω notation.

15
Transitive Properties:

If f(n) is O(g(n)) and g(n) is O(h(n)) then f(n) = O(h(n)).

Example:

If f(n) = n, g(n) = n² and h(n)=n³


Here n is O(n²) and n² is O(n³) then, n is O(n³)

Similarly, this property satisfies both Θ and Ω notation.

16
Symmetric Properties:
If f(n) is Θ(g(n)) then g(n) is Θ(f(n)).

Example:

If(n) = n² and g(n) = n²


then, f(n) = Θ(n²) and g(n) = Θ(n²)

This property only satisfies for Θ notation.

17
Transpose Symmetric Properties:

If f(n) is O(g(n)) then g(n) is Ω (f(n)).

Example:

If(n) = n , g(n) = n²
then n is O(n²) and n² is Ω (n)

This property only satisfies O and Ω notations.

18
Advantages of Asymptotic Notations
• Asymptotic analysis provides a high-level understanding of how an
algorithm performs with respect to input size.

• It is a useful tool for comparing the efficiency of different algorithms


and selecting the best one for a specific problem.

• It helps in predicting how an algorithm will perform on larger input


sizes, which is essential for real-world applications.

• Asymptotic analysis is relatively easy to perform and requires only


basic mathematical skills.

19
Disadvantages of Asymptotic Notations
• Asymptotic analysis does not provide an accurate running time or
space usage of an algorithm.

• It assumes that the input size is the only factor that affects an
algorithm’s performance, which is not always the case in practice.

• Asymptotic analysis can sometimes be misleading, as two


algorithms with the same asymptotic complexity may have different
actual running times or space usage.

• It is not always straightforward to determine the best asymptotic


complexity for an algorithm, as there may be trade-offs between time
and space complexity.
20
21

You might also like