0% found this document useful (0 votes)
45 views16 pages

Unit - 1: Analysis of Algorithm

- Asymptotic notations are used to represent the time complexity of algorithms and determine the most efficient algorithm. The main notations used are Big O (upper bound), Big Omega (lower bound), and Big Theta (tight bound). - Big O notation represents the worst-case upper bound of an algorithm. If function f(n) is less than or equal to a constant C multiplied by function g(n) as n approaches infinity, then f(n) is O(g(n)). - Examples show determining the Big O notation for constant, linear, quadratic, and other functions to find their upper bounds. Big O can identify the fastest growing component that bounds the running time.

Uploaded by

Raj Barasara
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)
45 views16 pages

Unit - 1: Analysis of Algorithm

- Asymptotic notations are used to represent the time complexity of algorithms and determine the most efficient algorithm. The main notations used are Big O (upper bound), Big Omega (lower bound), and Big Theta (tight bound). - Big O notation represents the worst-case upper bound of an algorithm. If function f(n) is less than or equal to a constant C multiplied by function g(n) as n approaches infinity, then f(n) is O(g(n)). - Examples show determining the Big O notation for constant, linear, quadratic, and other functions to find their upper bounds. Big O can identify the fastest growing component that bounds the running time.

Uploaded by

Raj Barasara
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/ 16

Unit – 1

Analysis of Algorithm
PREPARED BY:
RACHANA R. BUCH
Aymptotic Notations
• To choose best algorithm we need to check the efficiency of each algorithm.
• Efficiency can be measured by computing complexity of each algorithm.
• Complexity can be represented by asymptotic notations.
• Using asymptotic notations we can give time complexity as “fastest possible”,
“slowest possible” or “average time”.
Continue…
• Notations which are used to represent algorithm is known as asymptotic
notations.
• There are mainly 3 notations are used:
• Big oh (O)
• Big omega (Ω / W)
• Big theta (Θ)
Big oh (O) Notation
• The “Big oh” notation is denoted by ‘O’ (Capital ‘O’).
• This is a method of representing the upper bound of an algorithm’s running
time.
• It denotes largest amount of time taken by an algorithm to complete. (worst
case)
Definition
• Let f(n) and g(n) be two non negative functions.
• Let n0 and constant C are two integers such that n0 denotes some value of input
and n0 <=n, n0 >=1.
• Similarly C is some constant such that C>0 and
• F(n)<=C*g(n), then g(n) is upper bound of f(n).
• It can be denoted as f(n)=Og(n)
Note…
•Actually g(n) is not a single function but it’s a set of
functions which always grow faster than f(n) for
every n>=n0
Examples -1
• n2 grows slowly than n3
• n2 is Big oh of n3 n3 is upper bound of n2
Example – 2 Find upper bound of running time of
constant function f(n) = 6993
• Any value of C which is greater than
6993, satisfies the given inequalities,
so all such values of C are possible.
• Here f(n) =6993 which is a constant
value, that doesn’t depend on problem
size n, so, n0=1
• F(n) = O(g(n)) = O(1)
• For C = 6993 and n0=1
Example -3 Find upper bound of running time of linear
function f(n) = 6n+3
Continue…
• Other solution using tabular
approach
• 0<=f(n)<= c*g(n)
• 0<= 6n+3 <=7n

• Now let’s manually find out the


proper no such that
• f(n) <= C*g(n)
Example – 3 Find upper bound of running time of
quadratic function f(n)=3n2+2n+4

So, C=4, g(n)=n2 and n0=1


Example – 4 Find upper bound of running time of
quadratic function f(n)=6n2+135
n+1 n
Example – 5 Is 2 = O(2 )? Explain
Example – 6 f(n)=3n+2 and g(n)=n
Find upper bound of running time of f(n). Can f(n) be bounded by g(n) though upper bound?
Or Can f(n)=O(g(n))?
Or Can f(n) is big oh of g(n)?

So, g(n) is bounding f(n) such that f(n)<=C*g(n)


Thank
You

You might also like