SlideShare a Scribd company logo
1 of 18
Asymptotic Notations
               Nikhil Sharma
                 BE/8034/09
Introduction
 In mathematics, computer science, and related fields, big O
  notation describes the limiting behavior of a function when the
  argument tends towards a particular value or infinity, usually in
  terms of simpler functions. Big O notation allows its users to
  simplify functions in order to concentrate on their growth rates:
  different functions with the same growth rate may be represented
  using the same O notation.
 The time complexity of an algorithm quantifies the amount of
  time taken by an algorithm to run as a function of the size of the
  input to the problem. When it is expressed using big O
  notation, the time complexity is said to be
  described asymptotically, i.e., as the input size goes to infinity.
Asymptotic Complexity
   Running time of an algorithm as a function of input size n for large
    n.
   Expressed using only the highest-order term in the expression for
    the exact running time.
     ◦ Instead of exact running time, say (n2).
   Describes behavior of function in the limit.
   Written using Asymptotic Notation.
   The notations describe different rate-of-growth relations between
    the defining function and the defined set of functions.
O-notation
For function g(n), we define
O(g(n)), big-O of n, as the set:

O(g(n)) = {f(n) :
  positive constants c and n0, such
that n     n0,
we have 0      f(n) cg(n) }

Intuitively: Set of all functions
whose rate of growth is the same as
or lower than that of g(n).
g(n) is an asymptotic upper bound for f(n).

 f(n) = (g(n))   f(n) = O(g(n)).
   (g(n))  O(g(n)).
-notation
For function g(n), we define   (g(n)), big-
Omega of n, as the set:
 (g(n)) = {f(n) :
  positive constants c and n0, such
that n     n0,
we have 0 cg(n) f(n)}

Intuitively: Set of all functions
whose rate of growth is the same as
or higher than that of g(n).
g(n) is an asymptotic lower bound for f(n).
f(n) = (g(n))   f(n) =         (g(n)).
  (g(n))   (g(n)).
-notation
For function g(n), we define   (g(n)), big-
Theta of n, as the set:

  (g(n)) = {f(n) :
  positive constants c1, c2, and
n0, such that n    n 0,
we have 0 c1g(n)        f(n) c2g(n)
}
Intuitively: Set of all functions that
have the same rate of growth as g(n).

g(n) is an asymptotically tight bound for f(n).
Definitions
 Upper Bound Notation:
   ◦ f(n) is O(g(n)) if there exist positive constants c and n0 such
     that f(n) c g(n) for all n n0
   ◦ Formally, O(g(n)) = { f(n): positive constants c and n0 such
     that f(n) c g(n) n n0
   ◦ Big O fact: A polynomial of degree k is O(nk)
 Asymptotic lower bound:
   ◦ f(n) is (g(n)) if positive constants c and n0 such that
     0 c g(n) f(n)        n n0
 Asymptotic tight bound:
   ◦ f(n) is (g(n)) if positive constants c1, c2, and n0 such that
     c1 g(n) f(n) c2 g(n) n n0
   ◦ f(n) = (g(n)) if and only if
     f(n) = O(g(n)) AND f(n) = (g(n))
Relations Between   , O,
o-notation
For a given function g(n), the set little-o:

o(g(n)) = {f(n):     c > 0, n0 > 0 such that
                    n n0, we have 0  f(n) < cg(n)}.

 f(n) becomes insignificant relative to g(n) as n approaches
   infinity:
                 lim [f(n) / g(n)] = 0
                n

g(n) is an upper bound for f(n) that is not asymptotically tight.
-notation
For a given function g(n), the set little-omega:

  (g(n)) = {f(n):    c > 0, n0 > 0 such that
                    n n0, we have 0 cg(n) < f(n)}.



f(n) becomes arbitrarily large relative to g(n) as n approaches
   infinity:
                        lim [f(n) / g(n)] = .
                    n

g(n) is a lower bound for f(n) that is not asymptotically tight.
Comparison of Functions
              f   g    a   b

         f (n) = O(g(n))   a   b
          f (n) = (g(n))   a   b
         f (n) = (g(n))    a = b
         f (n) = o(g(n))   a < b
         f (n) = (g(n))    a > b
Review:
Other Asymptotic Notations
   Intuitively, we can simplify the above by:



    ■ o() is like <    ■    () is like >
                                             ■   () is like =
    ■ O() is like      ■    () is like
Exercise
 Express functions in A in asymptotic notation using functions in B.

  A                                 B

  5n2 + 100n                 3n2 + 2                          A    (B)

  A      (n2), n2    (B)     A      (B)

  log3(n2)                   log2(n3)                         A    (B)

  logba = logca / logcb; A = 2lgn / lg3, B = 3lgn, A/B =2/(3lg3)

  nlg4                               3lg n                    A     (B)

  alog b = blog a; B =3lg n=nlg 3; A/B =nlg(4/3)   as n

      lg2n                          n1/2                      A     (B)

  lim ( lga n / nb ) = 0 (here a = 2 and b = 1/2)         A       (B)
   n
Common growth rates

Time complexity            Example
O(1)           constant    Adding to the front of a linked list
O(log N)             log   Finding an entry in a sorted array
O(N)              linear   Finding an entry in an unsorted array
O(N log N)       n-log-n   Sorting n items by ‘divide-and-conquer’
O(N2)          quadratic   Shortest path between two nodes in a
                           graph
O(N3)             cubic    Simultaneous linear equations
O(2N)        exponential   The Towers of Hanoi problem
Growth rates
                                     O(N2)


                                             O(Nlog N)




  For a short time N2 is
  better than NlogN



                      Number of Inputs
Running Times
   “Running time is O(f(n))”    Worst case is O(f(n))
 O(f(n)) bound on the worst-case running time            O(f(n))
  bound on the running time of every input.
  (f(n)) bound on the worst-case running time             (f(n))
  bound on the running time of every input.
   “Running time is   (f(n))”   Best case is   (f(n))
   Can still say “Worst-case running time is   (f(n))”
    ◦ Means worst-case running time is given by some
      unspecified function g(n)   (f(n)).
Time Complexity Vs Space
Complexity
 Achieving both is difficult and we have to make use of the best
  case feasible
 There is always a trade off between the space and time
  complexity
 If memory available is large then we need not compensate on
  time complexity
 If speed of execution is not main concern and the memory
  available is less then we can’t compensate on space complexity.
The End

More Related Content

What's hot (20)

Sorting
SortingSorting
Sorting
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Floyd Warshall Algorithm
Floyd Warshall AlgorithmFloyd Warshall Algorithm
Floyd Warshall Algorithm
 
Time complexity
Time complexityTime complexity
Time complexity
 
Recursion
RecursionRecursion
Recursion
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Hashing
HashingHashing
Hashing
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 

Similar to Asymptotic notations

Similar to Asymptotic notations (20)

DAA_LECT_2.pdf
DAA_LECT_2.pdfDAA_LECT_2.pdf
DAA_LECT_2.pdf
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf
 
Clase3 Notacion
Clase3 NotacionClase3 Notacion
Clase3 Notacion
 
02 asymp
02 asymp02 asymp
02 asymp
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Asymtotic Appoach.ppt
Asymtotic Appoach.pptAsymtotic Appoach.ppt
Asymtotic Appoach.ppt
 
02-asymp.ppt
02-asymp.ppt02-asymp.ppt
02-asymp.ppt
 
Asymptotic notation ada
Asymptotic notation adaAsymptotic notation ada
Asymptotic notation ada
 
big_oh
big_ohbig_oh
big_oh
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
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
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.ppt
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt
 
Time complexity
Time complexityTime complexity
Time complexity
 
Weekends with Competitive Programming
Weekends with Competitive ProgrammingWeekends with Competitive Programming
Weekends with Competitive Programming
 
Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdf
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
 

More from Nikhil Sharma

More from Nikhil Sharma (6)

Digital Life
Digital LifeDigital Life
Digital Life
 
B tree short
B tree shortB tree short
B tree short
 
B tree long
B tree longB tree long
B tree long
 
India
IndiaIndia
India
 
Curse of dimensionality
Curse of dimensionalityCurse of dimensionality
Curse of dimensionality
 
Impurities in wastewater & problems caused by it
Impurities in wastewater & problems caused by itImpurities in wastewater & problems caused by it
Impurities in wastewater & problems caused by it
 

Recently uploaded

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Recently uploaded (20)

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Asymptotic notations

  • 1. Asymptotic Notations Nikhil Sharma BE/8034/09
  • 2. Introduction  In mathematics, computer science, and related fields, big O notation describes the limiting behavior of a function when the argument tends towards a particular value or infinity, usually in terms of simpler functions. Big O notation allows its users to simplify functions in order to concentrate on their growth rates: different functions with the same growth rate may be represented using the same O notation.  The time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the size of the input to the problem. When it is expressed using big O notation, the time complexity is said to be described asymptotically, i.e., as the input size goes to infinity.
  • 3. Asymptotic Complexity  Running time of an algorithm as a function of input size n for large n.  Expressed using only the highest-order term in the expression for the exact running time. ◦ Instead of exact running time, say (n2).  Describes behavior of function in the limit.  Written using Asymptotic Notation.  The notations describe different rate-of-growth relations between the defining function and the defined set of functions.
  • 4. O-notation For function g(n), we define O(g(n)), big-O of n, as the set: O(g(n)) = {f(n) : positive constants c and n0, such that n n0, we have 0 f(n) cg(n) } Intuitively: Set of all functions whose rate of growth is the same as or lower than that of g(n). g(n) is an asymptotic upper bound for f(n). f(n) = (g(n)) f(n) = O(g(n)). (g(n)) O(g(n)).
  • 5. -notation For function g(n), we define (g(n)), big- Omega of n, as the set: (g(n)) = {f(n) : positive constants c and n0, such that n n0, we have 0 cg(n) f(n)} Intuitively: Set of all functions whose rate of growth is the same as or higher than that of g(n). g(n) is an asymptotic lower bound for f(n). f(n) = (g(n)) f(n) = (g(n)). (g(n)) (g(n)).
  • 6. -notation For function g(n), we define (g(n)), big- Theta of n, as the set: (g(n)) = {f(n) : positive constants c1, c2, and n0, such that n n 0, we have 0 c1g(n) f(n) c2g(n) } Intuitively: Set of all functions that have the same rate of growth as g(n). g(n) is an asymptotically tight bound for f(n).
  • 7. Definitions  Upper Bound Notation: ◦ f(n) is O(g(n)) if there exist positive constants c and n0 such that f(n) c g(n) for all n n0 ◦ Formally, O(g(n)) = { f(n): positive constants c and n0 such that f(n) c g(n) n n0 ◦ Big O fact: A polynomial of degree k is O(nk)  Asymptotic lower bound: ◦ f(n) is (g(n)) if positive constants c and n0 such that 0 c g(n) f(n) n n0  Asymptotic tight bound: ◦ f(n) is (g(n)) if positive constants c1, c2, and n0 such that c1 g(n) f(n) c2 g(n) n n0 ◦ f(n) = (g(n)) if and only if f(n) = O(g(n)) AND f(n) = (g(n))
  • 9. o-notation For a given function g(n), the set little-o: o(g(n)) = {f(n): c > 0, n0 > 0 such that n n0, we have 0 f(n) < cg(n)}. f(n) becomes insignificant relative to g(n) as n approaches infinity: lim [f(n) / g(n)] = 0 n g(n) is an upper bound for f(n) that is not asymptotically tight.
  • 10. -notation For a given function g(n), the set little-omega: (g(n)) = {f(n): c > 0, n0 > 0 such that n n0, we have 0 cg(n) < f(n)}. f(n) becomes arbitrarily large relative to g(n) as n approaches infinity: lim [f(n) / g(n)] = . n g(n) is a lower bound for f(n) that is not asymptotically tight.
  • 11. Comparison of Functions f g a b f (n) = O(g(n)) a b f (n) = (g(n)) a b f (n) = (g(n)) a = b f (n) = o(g(n)) a < b f (n) = (g(n)) a > b
  • 12. Review: Other Asymptotic Notations  Intuitively, we can simplify the above by: ■ o() is like < ■ () is like > ■ () is like = ■ O() is like ■ () is like
  • 13. Exercise Express functions in A in asymptotic notation using functions in B. A B 5n2 + 100n 3n2 + 2 A (B) A (n2), n2 (B) A (B) log3(n2) log2(n3) A (B) logba = logca / logcb; A = 2lgn / lg3, B = 3lgn, A/B =2/(3lg3) nlg4 3lg n A (B) alog b = blog a; B =3lg n=nlg 3; A/B =nlg(4/3) as n lg2n n1/2 A (B) lim ( lga n / nb ) = 0 (here a = 2 and b = 1/2) A (B) n
  • 14. Common growth rates Time complexity Example O(1) constant Adding to the front of a linked list O(log N) log Finding an entry in a sorted array O(N) linear Finding an entry in an unsorted array O(N log N) n-log-n Sorting n items by ‘divide-and-conquer’ O(N2) quadratic Shortest path between two nodes in a graph O(N3) cubic Simultaneous linear equations O(2N) exponential The Towers of Hanoi problem
  • 15. Growth rates O(N2) O(Nlog N) For a short time N2 is better than NlogN Number of Inputs
  • 16. Running Times  “Running time is O(f(n))” Worst case is O(f(n))  O(f(n)) bound on the worst-case running time O(f(n)) bound on the running time of every input.  (f(n)) bound on the worst-case running time (f(n)) bound on the running time of every input.  “Running time is (f(n))” Best case is (f(n))  Can still say “Worst-case running time is (f(n))” ◦ Means worst-case running time is given by some unspecified function g(n) (f(n)).
  • 17. Time Complexity Vs Space Complexity  Achieving both is difficult and we have to make use of the best case feasible  There is always a trade off between the space and time complexity  If memory available is large then we need not compensate on time complexity  If speed of execution is not main concern and the memory available is less then we can’t compensate on space complexity.