SlideShare a Scribd company logo
Asymptotic Analysis-1
Asymptotic Analysis-1
Topics
 Objectives
 Asymptotic Notation
 Definitions ( Big-Oh, Big-Omega and Theta)
 Asymptotic Notation Theorems
Asymptotic Analysis
Objectives
 The purpose of asymptotic analysis is to examine the behavior of an algorithm for large
input size. More specifically, if T(n) is the running time for an input of size n , we would
want to know the behavior or growth rate of T(n) for very large values of n. An analysis of
algorithm for large input is referred to as asymptotic analysis.
 The asymptotic behavior of an algorithm is often compared to some standard
mathematical function, such as n2, n lg n etc The relationship or similarity of behavior is
often expressed by a special notation which is called asymptotic notation.
 The standard asymptotic notations commonly used in the analysis of algorithms are known
as O (Big Oh), Ω (Big Omega), and θ(Theta).
 Sometimes, additional notations o( small-oh) and ω( small-omega) are also used to show
the growth rates of algorithms
Asymptotic Notation
O-Notation
Definition
If f(n) is running time of an algorithm, and g(n) is some standard growth function such that
for some positive constants c and integer n0 ,
f(n) ≤ c.g(n) for all n ≥ n0
then f(n) = O(g(n)) (Read f(n) is Big-Oh of g(n) )
 The behavior of f(n) and g(n) is portrayed in the diagram. It follows that for n<n0, ,f(n) may
lie above or below g(n), but for all n ≥ n0, f(n) falls consistently below g(n)..
Trend of running time
O-Notation
Asymptotic Upper Bound
Asymptotic Upper Bound
If f(n) = O(g(n)), then the function g(n) is called asymptotic upper bound of f(n)
Since the worst-case running time of an algorithm is the maximum running time for any
input, it would follow that g(n) provides an upper bound on the worst running time
The notation O( g(n) ) does not imply that g(n) is the worse running time; it simply means
that worst running time would never exceed upper limit determined by g(n).
Asymptotic Upper Bound of f(n)
O-Notation
cg(n)=4n2
f(n)=3n2 + 10 n
cg(n)= 13n2
O-Notation Example
Comparison of Growth Rates
The results of analysis in the preceding examples are plotted in the diagram below.
It can be seen that the function cg(n) =4n2 ( c= 4) overshoots the function f(n)= 3n2 + 10n
for n0=10. Also, the function cg(n) =13n2 ( c =13 ) grows faster than f(n) = 3n2 + 10n for
n0=1
n0=1 n0=10
Growth of functions 13n2 and 4n2 versus the function 3n2 + 10 n
Set Builder O-Notation
Definition
 Consider the functions , say f1(n), f2(n), f3(n), ..fk(n) for which g(n) is the asymptotic
upper bound. By definition,
f1(n) ≤ c1 g(n) for n ≥ n1
f2(n) ≤ c2 g(n) for n ≥ n2
f3(n) ≤ c3 g(n) for n ≥ n3
……………………
fk(n) ≤ ck g(n) for ≥ nk
where c1, c2, c3 ,.. ck are constants and n1 ,n2 ,n3,.. nk are positive integers. The functions f1(n),
f2(n), f3(n), .. fk(n) are said to belong to the class O( g(n)). In set notation, the relation is
denoted by
O( g(n) )= { f1(n) , f2(n), f3(n)…,fk(n)}
 Alternatively, using set-builder notation, if
O(g(n)) ={ f(n): there exist positive constants c and n0, such that f(n) ≤ c.g(n), for all n ≥ n0 }
then, f(n) 

O(g(n))
Ω-Notation
Definition
If f(n) is running time of an algorithm, and g(n) is some standard growth function such that
for some positive constants c, positive integer n0 ,
c.g(n) ≤ f(n) for all n ≥ n0
then f(n) = Ω(g(n)) (Read f(n) is Big-Omega of g(n) )
 The behavior of f(n) and g(n) is portrayed in the graph. It follows that for n < n0, f(n) may
lie above or below g(n), but for all n ≥ n0, f(n) falls consistently above g(n). It also implies that
g(n) grows slower than f(n)
Trend of running time
Ω-Notation
Asymptotic Lower Bound
Asymptotic Lower Bound
If f(n) = Ω(g(n)), then the function g(n) is called asymptotic lower bound of f(n)
Since the best-case running time of an algorithm is the minimum running time for any input,
it would follow that g(n) provides a lower bound on best running time
As before, the notation Ω( g(n) ) does not imply that g(n) is the best running time; it simply
means that best running time would never be lower than g(n).
Asymptotic lower bound of f(n)
Ω-Notation
Set Builder Ω-Notation
 hich g(n) is the asymptotic lower bound. By definition,
f1(n) ≥ c1 g(n) for n ≥ n1
f2(n) ≥ c2 g(n) for n ≥ n2
f3(n) ≥ c3 g(n) for n ≥ n3
……………………
fk(n) ≥ ck g(n) for ≥ nk
where c1, c2, c3 ,.. ck are constants and n1 ,n2 ,n3,.. nk are positive integers. The functions f1(n),
f2(n), f3(n), .. fk(n) are said to belong to the class Ω(g(n)). In set notation, the relation is
denoted by
Ω( g(n) )= { f1(n) , f2(n), f3(n)…,fk(n)}
 Alternatively, using set-builder notation , if
Ω(g(n)) ={ f(n): there exist positive constants c and n0, such that f(n) ≥ c.g(n), for all n ≥ n0 }
then f(n) 

Ω(g(n))
θ-Notation
Definition
If f(n) is running time of an algorithm, and g(n) is some standard growth function
such that for some positive constants c1 , c2 and positive integer n0 ,
0 < c2.g(n) ≤ f(n) ≤ c1.g(n) for all n ≥ n0
then f(n) = θ(g(n)) (Read f(n) is theta of g(n) )
 The behavior of f(n) and g(n) is portrayed in the graph. It follows that for n < n0, f(n) may
be above or below g(n), but for all n ≥ n0, f(n) falls consistently between c1.g(n) and c2.g(n).
It also implies that g(n) grows as fast as f(n) The function g(n) is said to be the asymptotic
tight bound for f(n)
Asymptotic tight bound of f(n)
Asymptotic Upper Bound
Asymptotic Lower Bound
Set Builder θ-Notation
Definition
 There can be a several functions for which the g(n) is asymptotic tight bound. All such
functions are said to belong to the class Ө(g(n))
 Using set builder notation,, if
Ө(g(n)) = { f(n): there exit positive constants c1,c2 and positive integer n0 such that
c1 g(n) ≤ f(n) ≤ c2 g(n) }
then f(n)  θ(g(n))
Asymptotic Notation
Constant Running Time
 If running time T(n)=c is a constant, i. e independent of input size, then by convention,
the asymptotic behavior is denoted by the notation
O(c) = O(1) , θ (c) = θ(1), Ω(c) = Ω(1)
 The convention implies that the running time of an algorithm ,which does not depend
on the size of input, can be expressed in any of the above ways.
 If c is constant then using basic definition it can be shown that
O( c.f(n) ) = O( f(n) )
θ( c.f(n) ) = θ( f(n) )
Ω( c.f(n) ) = Ω( f(n ))
Example: (i) O(1000n) = O(n),
(ii) θ(7lgn ) = θ (lg n),
(ii) Ω(100 n!) = Ω(n!)
 The above results imply that in asymptotic notation the multiplier constants in an
expression for the running time can be dropped
Asymptotic Notations
Theorem: If f(n) = θ( g(n) ) then
Relationships
f(n) = Ω( g(n) ), and f(n)= O( g(n) )
Conversely, if f(n) = Ω( g(n) ) and f(n) = O( g(n) )
then f(n) = θ( g(n) )
 The above relations can be established by using basic definitions
Example(1): Since, n(n-1)/2 = θ(n2 ), therefore it follows that
n(n-1)/2 = Ω(n2 )
n(n-1)/2 = O(n2 )
Example(2): It can be shown that
5n2+1 = Ω(n2 )
and 5n2+1 = O(n2 )
Therefore, 5n2 + 1 = θ(n2 )
Asymptotic Set Notations
O(g(n)) Ө(g(n)) Ω(g(n))
Relationship
We have seen that if f(n) = O( g(n) ) and f(n) = Ω(g(n)) then f(n) = Ө( g(n) )
Using set notation we can express the relationship as follows:
if f(n)O( g(n) ),
and f(n)Ω (g(n)),
then f(n) Ө( g(n) ) ,
where Ө(g(n)) = O( g(n) ) ∩ Ω (g(n) )
 The above property is illustrated by the following Venn diagram
Asymptotic Notation
Order Theorem
Theorem: If f1(n) = O( g1(n) ) and f2(n) = O( g2(n) ) then
f1(n) + f2(n)= O( max( g1(n) , g2(n) )
Proof: By definition,
f1(n) ≤ c1. g1(n) for n ≥ n1
f2(n) ≤ c2. g2(n) for n ≥ n2
Let n0 = max(n1, n2) c3=max(c1, c2)
f1(n) ≤ c3. g1(n) for n ≥ n0
f2(n) ≤ c3 g2(n) for n ≥ n0
f1(n) + f2(n) ≤ c3.g1(n) + c3. g2(n) )
Let h(n) = max( g1(n) , g2(n) )
for n ≥ n0
f1(n) + f2(n) ≤ 2c3.h(n) = c. h(n) where c=2c3
f1(n) + f2(n) ≤ c. h(n) = c. max( g1(n) , g2(n) )
Therefore, f1(n) + f2(n) = O( max( g1(n) , g2(n) )
 The theorem also applies to θ and Ω notations
for n ≥ n0
for n ≥ n0
General Theorem
Theorem: If f1(n)= O(g1(n)) , f2(n) =O(g2(n)), f3(n)=O(g3(n))…., fk(n)=O(gk(n)) then
f1(n) + f2(n) + f3(n) ….+ fk(n) = O( max (g1 (n), g2 (n), g3 (n)…, gk(n) ) )
where max means fastest growing function
The theorem can be proved by using basic definition of Big-Oh
 It follows from the theorem that in an expression consisting of sum of several functions,
the comparatively slower growing functions can be discarded in favor of the fastest
growing function to obtain the Big oh notation for the whole expression This also true for
the Ө and Ω notations
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf

More Related Content

What's hot

Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Farzana Aktar
 
Lesson 03
Lesson 03Lesson 03
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
ER Punit Jain
 
Turing machine and Halting Introduction
Turing machine and Halting IntroductionTuring machine and Halting Introduction
Turing machine and Halting Introduction
AmartyaYandrapu1
 
Modeling with Recurrence Relations
Modeling with Recurrence RelationsModeling with Recurrence Relations
Modeling with Recurrence Relations
Devanshu Taneja
 
Big omega
Big omegaBig omega
Big omega
Rajesh K Shukla
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
Samita Mukesh
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
DataminingTools Inc
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Fuzzy Logic
Fuzzy LogicFuzzy Logic
Fuzzy Logic
Rishikese MR
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAdelina Ahadova
 
Natural Language processing Parts of speech tagging, its classes, and how to ...
Natural Language processing Parts of speech tagging, its classes, and how to ...Natural Language processing Parts of speech tagging, its classes, and how to ...
Natural Language processing Parts of speech tagging, its classes, and how to ...
Rajnish Raj
 
Alpha beta pruning in ai
Alpha beta pruning in aiAlpha beta pruning in ai
Alpha beta pruning in ai
Savyasachi14
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
Akshaya Arunan
 
Quotient ring
Quotient ringQuotient ring
Quotient ring
Muhammad Umar Farooq
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
Hemantha Kulathilake
 
Linguistic variable
Linguistic variable Linguistic variable
Linguistic variable
Math-Circle
 
Elimination of left recursion
Elimination of left recursionElimination of left recursion
Elimination of left recursion
Mahmudul Hasan
 
Infinite sequences and series i
Infinite sequences and series iInfinite sequences and series i
Infinite sequences and series i
EasyStudy3
 
Fuzzy+logic
Fuzzy+logicFuzzy+logic
Fuzzy+logic
Mahesh Todkar
 

What's hot (20)

Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Turing machine and Halting Introduction
Turing machine and Halting IntroductionTuring machine and Halting Introduction
Turing machine and Halting Introduction
 
Modeling with Recurrence Relations
Modeling with Recurrence RelationsModeling with Recurrence Relations
Modeling with Recurrence Relations
 
Big omega
Big omegaBig omega
Big omega
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Fuzzy Logic
Fuzzy LogicFuzzy Logic
Fuzzy Logic
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
 
Natural Language processing Parts of speech tagging, its classes, and how to ...
Natural Language processing Parts of speech tagging, its classes, and how to ...Natural Language processing Parts of speech tagging, its classes, and how to ...
Natural Language processing Parts of speech tagging, its classes, and how to ...
 
Alpha beta pruning in ai
Alpha beta pruning in aiAlpha beta pruning in ai
Alpha beta pruning in ai
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
 
Quotient ring
Quotient ringQuotient ring
Quotient ring
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
 
Linguistic variable
Linguistic variable Linguistic variable
Linguistic variable
 
Elimination of left recursion
Elimination of left recursionElimination of left recursion
Elimination of left recursion
 
Infinite sequences and series i
Infinite sequences and series iInfinite sequences and series i
Infinite sequences and series i
 
Fuzzy+logic
Fuzzy+logicFuzzy+logic
Fuzzy+logic
 

Similar to Lecture 3(a) Asymptotic-analysis.pdf

Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdf
ShaistaRiaz4
 
Clase3 Notacion
Clase3 NotacionClase3 Notacion
Clase3 Notacion
luzenith_g
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
Protap Mondal
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
Saranya Natarajan
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations i
Ali mahmood
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.ppt
ZohairMughal1
 
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptLecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).ppt
ZohairMughal1
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
mustafa sarac
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
sajinis3
 
Theta notation
Theta notationTheta notation
Theta notation
Rajesh K Shukla
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
S.Shayan Daneshvar
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
Rajandeep Gill
 
Weekends with Competitive Programming
Weekends with Competitive ProgrammingWeekends with Competitive Programming
Weekends with Competitive Programming
NiharikaSingh839269
 
DAA_LECT_2.pdf
DAA_LECT_2.pdfDAA_LECT_2.pdf
DAA_LECT_2.pdf
AryanSaini69
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
srushtiivp
 

Similar to Lecture 3(a) Asymptotic-analysis.pdf (20)

Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdf
 
Clase3 Notacion
Clase3 NotacionClase3 Notacion
Clase3 Notacion
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
big_oh
big_ohbig_oh
big_oh
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations i
 
02 asymp
02 asymp02 asymp
02 asymp
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.ppt
 
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptLecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).ppt
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Theta notation
Theta notationTheta notation
Theta notation
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Weekends with Competitive Programming
Weekends with Competitive ProgrammingWeekends with Competitive Programming
Weekends with Competitive Programming
 
DAA_LECT_2.pdf
DAA_LECT_2.pdfDAA_LECT_2.pdf
DAA_LECT_2.pdf
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
 

More from ShaistaRiaz4

Algorithms Analysis.pdf
Algorithms Analysis.pdfAlgorithms Analysis.pdf
Algorithms Analysis.pdf
ShaistaRiaz4
 
Case Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdfCase Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdf
ShaistaRiaz4
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt
ShaistaRiaz4
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.ppt
ShaistaRiaz4
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
ShaistaRiaz4
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt
ShaistaRiaz4
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.ppt
ShaistaRiaz4
 
Bisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdfBisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdf
ShaistaRiaz4
 
MNS Lecture 1.pptx
MNS Lecture 1.pptxMNS Lecture 1.pptx
MNS Lecture 1.pptx
ShaistaRiaz4
 
Plan (2).pptx
Plan (2).pptxPlan (2).pptx
Plan (2).pptx
ShaistaRiaz4
 
Lecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdfLecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdf
ShaistaRiaz4
 
oppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptxoppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptx
ShaistaRiaz4
 
Development Education.pptx
Development Education.pptxDevelopment Education.pptx
Development Education.pptx
ShaistaRiaz4
 
WISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.pptWISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.ppt
ShaistaRiaz4
 
Summary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptxSummary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptx
ShaistaRiaz4
 
MH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.pptMH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.ppt
ShaistaRiaz4
 
Intro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.pptIntro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.ppt
ShaistaRiaz4
 
Coping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.pptCoping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.ppt
ShaistaRiaz4
 
Intellectual_development.ppt
Intellectual_development.pptIntellectual_development.ppt
Intellectual_development.ppt
ShaistaRiaz4
 
Integrating Technology Models.pptx
Integrating Technology Models.pptxIntegrating Technology Models.pptx
Integrating Technology Models.pptx
ShaistaRiaz4
 

More from ShaistaRiaz4 (20)

Algorithms Analysis.pdf
Algorithms Analysis.pdfAlgorithms Analysis.pdf
Algorithms Analysis.pdf
 
Case Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdfCase Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdf
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.ppt
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.ppt
 
Bisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdfBisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdf
 
MNS Lecture 1.pptx
MNS Lecture 1.pptxMNS Lecture 1.pptx
MNS Lecture 1.pptx
 
Plan (2).pptx
Plan (2).pptxPlan (2).pptx
Plan (2).pptx
 
Lecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdfLecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdf
 
oppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptxoppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptx
 
Development Education.pptx
Development Education.pptxDevelopment Education.pptx
Development Education.pptx
 
WISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.pptWISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.ppt
 
Summary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptxSummary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptx
 
MH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.pptMH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.ppt
 
Intro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.pptIntro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.ppt
 
Coping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.pptCoping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.ppt
 
Intellectual_development.ppt
Intellectual_development.pptIntellectual_development.ppt
Intellectual_development.ppt
 
Integrating Technology Models.pptx
Integrating Technology Models.pptxIntegrating Technology Models.pptx
Integrating Technology Models.pptx
 

Recently uploaded

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 

Recently uploaded (20)

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 

Lecture 3(a) Asymptotic-analysis.pdf

  • 1.
  • 3. Asymptotic Analysis-1 Topics  Objectives  Asymptotic Notation  Definitions ( Big-Oh, Big-Omega and Theta)  Asymptotic Notation Theorems
  • 4. Asymptotic Analysis Objectives  The purpose of asymptotic analysis is to examine the behavior of an algorithm for large input size. More specifically, if T(n) is the running time for an input of size n , we would want to know the behavior or growth rate of T(n) for very large values of n. An analysis of algorithm for large input is referred to as asymptotic analysis.  The asymptotic behavior of an algorithm is often compared to some standard mathematical function, such as n2, n lg n etc The relationship or similarity of behavior is often expressed by a special notation which is called asymptotic notation.  The standard asymptotic notations commonly used in the analysis of algorithms are known as O (Big Oh), Ω (Big Omega), and θ(Theta).  Sometimes, additional notations o( small-oh) and ω( small-omega) are also used to show the growth rates of algorithms
  • 6. O-Notation Definition If f(n) is running time of an algorithm, and g(n) is some standard growth function such that for some positive constants c and integer n0 , f(n) ≤ c.g(n) for all n ≥ n0 then f(n) = O(g(n)) (Read f(n) is Big-Oh of g(n) )  The behavior of f(n) and g(n) is portrayed in the diagram. It follows that for n<n0, ,f(n) may lie above or below g(n), but for all n ≥ n0, f(n) falls consistently below g(n).. Trend of running time
  • 7. O-Notation Asymptotic Upper Bound Asymptotic Upper Bound If f(n) = O(g(n)), then the function g(n) is called asymptotic upper bound of f(n) Since the worst-case running time of an algorithm is the maximum running time for any input, it would follow that g(n) provides an upper bound on the worst running time The notation O( g(n) ) does not imply that g(n) is the worse running time; it simply means that worst running time would never exceed upper limit determined by g(n). Asymptotic Upper Bound of f(n)
  • 9. cg(n)=4n2 f(n)=3n2 + 10 n cg(n)= 13n2 O-Notation Example Comparison of Growth Rates The results of analysis in the preceding examples are plotted in the diagram below. It can be seen that the function cg(n) =4n2 ( c= 4) overshoots the function f(n)= 3n2 + 10n for n0=10. Also, the function cg(n) =13n2 ( c =13 ) grows faster than f(n) = 3n2 + 10n for n0=1 n0=1 n0=10 Growth of functions 13n2 and 4n2 versus the function 3n2 + 10 n
  • 10. Set Builder O-Notation Definition  Consider the functions , say f1(n), f2(n), f3(n), ..fk(n) for which g(n) is the asymptotic upper bound. By definition, f1(n) ≤ c1 g(n) for n ≥ n1 f2(n) ≤ c2 g(n) for n ≥ n2 f3(n) ≤ c3 g(n) for n ≥ n3 …………………… fk(n) ≤ ck g(n) for ≥ nk where c1, c2, c3 ,.. ck are constants and n1 ,n2 ,n3,.. nk are positive integers. The functions f1(n), f2(n), f3(n), .. fk(n) are said to belong to the class O( g(n)). In set notation, the relation is denoted by O( g(n) )= { f1(n) , f2(n), f3(n)…,fk(n)}  Alternatively, using set-builder notation, if O(g(n)) ={ f(n): there exist positive constants c and n0, such that f(n) ≤ c.g(n), for all n ≥ n0 } then, f(n)   O(g(n))
  • 11. Ω-Notation Definition If f(n) is running time of an algorithm, and g(n) is some standard growth function such that for some positive constants c, positive integer n0 , c.g(n) ≤ f(n) for all n ≥ n0 then f(n) = Ω(g(n)) (Read f(n) is Big-Omega of g(n) )  The behavior of f(n) and g(n) is portrayed in the graph. It follows that for n < n0, f(n) may lie above or below g(n), but for all n ≥ n0, f(n) falls consistently above g(n). It also implies that g(n) grows slower than f(n) Trend of running time
  • 12. Ω-Notation Asymptotic Lower Bound Asymptotic Lower Bound If f(n) = Ω(g(n)), then the function g(n) is called asymptotic lower bound of f(n) Since the best-case running time of an algorithm is the minimum running time for any input, it would follow that g(n) provides a lower bound on best running time As before, the notation Ω( g(n) ) does not imply that g(n) is the best running time; it simply means that best running time would never be lower than g(n). Asymptotic lower bound of f(n)
  • 14. Set Builder Ω-Notation  hich g(n) is the asymptotic lower bound. By definition, f1(n) ≥ c1 g(n) for n ≥ n1 f2(n) ≥ c2 g(n) for n ≥ n2 f3(n) ≥ c3 g(n) for n ≥ n3 …………………… fk(n) ≥ ck g(n) for ≥ nk where c1, c2, c3 ,.. ck are constants and n1 ,n2 ,n3,.. nk are positive integers. The functions f1(n), f2(n), f3(n), .. fk(n) are said to belong to the class Ω(g(n)). In set notation, the relation is denoted by Ω( g(n) )= { f1(n) , f2(n), f3(n)…,fk(n)}  Alternatively, using set-builder notation , if Ω(g(n)) ={ f(n): there exist positive constants c and n0, such that f(n) ≥ c.g(n), for all n ≥ n0 } then f(n)   Ω(g(n))
  • 15. θ-Notation Definition If f(n) is running time of an algorithm, and g(n) is some standard growth function such that for some positive constants c1 , c2 and positive integer n0 , 0 < c2.g(n) ≤ f(n) ≤ c1.g(n) for all n ≥ n0 then f(n) = θ(g(n)) (Read f(n) is theta of g(n) )  The behavior of f(n) and g(n) is portrayed in the graph. It follows that for n < n0, f(n) may be above or below g(n), but for all n ≥ n0, f(n) falls consistently between c1.g(n) and c2.g(n). It also implies that g(n) grows as fast as f(n) The function g(n) is said to be the asymptotic tight bound for f(n) Asymptotic tight bound of f(n) Asymptotic Upper Bound Asymptotic Lower Bound
  • 16. Set Builder θ-Notation Definition  There can be a several functions for which the g(n) is asymptotic tight bound. All such functions are said to belong to the class Ө(g(n))  Using set builder notation,, if Ө(g(n)) = { f(n): there exit positive constants c1,c2 and positive integer n0 such that c1 g(n) ≤ f(n) ≤ c2 g(n) } then f(n)  θ(g(n))
  • 17. Asymptotic Notation Constant Running Time  If running time T(n)=c is a constant, i. e independent of input size, then by convention, the asymptotic behavior is denoted by the notation O(c) = O(1) , θ (c) = θ(1), Ω(c) = Ω(1)  The convention implies that the running time of an algorithm ,which does not depend on the size of input, can be expressed in any of the above ways.  If c is constant then using basic definition it can be shown that O( c.f(n) ) = O( f(n) ) θ( c.f(n) ) = θ( f(n) ) Ω( c.f(n) ) = Ω( f(n )) Example: (i) O(1000n) = O(n), (ii) θ(7lgn ) = θ (lg n), (ii) Ω(100 n!) = Ω(n!)  The above results imply that in asymptotic notation the multiplier constants in an expression for the running time can be dropped
  • 18. Asymptotic Notations Theorem: If f(n) = θ( g(n) ) then Relationships f(n) = Ω( g(n) ), and f(n)= O( g(n) ) Conversely, if f(n) = Ω( g(n) ) and f(n) = O( g(n) ) then f(n) = θ( g(n) )  The above relations can be established by using basic definitions Example(1): Since, n(n-1)/2 = θ(n2 ), therefore it follows that n(n-1)/2 = Ω(n2 ) n(n-1)/2 = O(n2 ) Example(2): It can be shown that 5n2+1 = Ω(n2 ) and 5n2+1 = O(n2 ) Therefore, 5n2 + 1 = θ(n2 )
  • 19. Asymptotic Set Notations O(g(n)) Ө(g(n)) Ω(g(n)) Relationship We have seen that if f(n) = O( g(n) ) and f(n) = Ω(g(n)) then f(n) = Ө( g(n) ) Using set notation we can express the relationship as follows: if f(n)O( g(n) ), and f(n)Ω (g(n)), then f(n) Ө( g(n) ) , where Ө(g(n)) = O( g(n) ) ∩ Ω (g(n) )  The above property is illustrated by the following Venn diagram
  • 20. Asymptotic Notation Order Theorem Theorem: If f1(n) = O( g1(n) ) and f2(n) = O( g2(n) ) then f1(n) + f2(n)= O( max( g1(n) , g2(n) ) Proof: By definition, f1(n) ≤ c1. g1(n) for n ≥ n1 f2(n) ≤ c2. g2(n) for n ≥ n2 Let n0 = max(n1, n2) c3=max(c1, c2) f1(n) ≤ c3. g1(n) for n ≥ n0 f2(n) ≤ c3 g2(n) for n ≥ n0 f1(n) + f2(n) ≤ c3.g1(n) + c3. g2(n) ) Let h(n) = max( g1(n) , g2(n) ) for n ≥ n0 f1(n) + f2(n) ≤ 2c3.h(n) = c. h(n) where c=2c3 f1(n) + f2(n) ≤ c. h(n) = c. max( g1(n) , g2(n) ) Therefore, f1(n) + f2(n) = O( max( g1(n) , g2(n) )  The theorem also applies to θ and Ω notations for n ≥ n0 for n ≥ n0
  • 21. General Theorem Theorem: If f1(n)= O(g1(n)) , f2(n) =O(g2(n)), f3(n)=O(g3(n))…., fk(n)=O(gk(n)) then f1(n) + f2(n) + f3(n) ….+ fk(n) = O( max (g1 (n), g2 (n), g3 (n)…, gk(n) ) ) where max means fastest growing function The theorem can be proved by using basic definition of Big-Oh  It follows from the theorem that in an expression consisting of sum of several functions, the comparatively slower growing functions can be discarded in favor of the fastest growing function to obtain the Big oh notation for the whole expression This also true for the Ө and Ω notations