SlideShare a Scribd company logo
1
ASYMPTOTICS NOTATIONS
O-notation (Big Oh)
Asymptotic Upper Bound
For a given function g(n), we denote O(g(n)) as the set of
functions:
O(g(n)) = { f(n)| there exists positive constants c and n0
such that 0 ≤ f(n) ≤ c g(n) for all n ≥ n0 }
It is used to represent the worst case growth of an algorithm
in time or a data structure in space when they are
dependent on n, where n is big enough
Example :
8/10/2021
2
Big Oh - Example
f(n) = n2
+ 5n = O(n2)
g(n) = n2
……… c = 2
n n2
+ 5n 2n2
1 5 2
2 14 8
5 50 50
f(n) <= c g(n) for all n> = n0 where c=2 & n0 =5
8/10/2021
3
Big Oh - Example
Let f(N) = 2N2
. Then
◦ f(N) = O(N4
) (loose bound)
◦ f(N) = O(N3
) (loose bound)
◦ f(N) = O(N2
) (It is the best answer and the bound is asymptotically tight.)
O(N2
): reads “order N-squared” or “Big-Oh N-squared”.
8/10/2021
4
Big Oh - Example
Prove that if T(n) = 15n3
+ n2
+ 4, T(n) = O(n3
).
Proof.
Let c = 20 and n0 = 1.
Must show that 0 ≤ f (n) and f (n) ≤ cg(n).
0≤15n3
+ n2
+ 4 for all n ≥ n0 = 1.
f (n) = 15n3
+ n2
+ 4 ≤ 20n3
(20g(n) = cg(n))
As per defination of Big O, hence T(n) = O(n3
)
8/10/2021
5
ASYMPTOTICS NOTATIONS
Ω-notation
Asymptotic lower bound
Ω (g(n)) represents a set of functions such that:
Ω(g(n)) = {f(n): there exist positive
constants c and n0 such that
0 ≤ c g(n) ≤ f(n) for all n≥ n0}
8/10/2021
6
Big Omega - Example
Example 1 :
f(n) = n2
+ 5n
g(n) = n2
……… c = 1
n n2
+ 5n c*n2
1 5 1
2 14 4
5 50 25
f(n) >= c g(n) for all n> = n0 where c=1 & n0
=1
Example 1 :
Prove that if T(n) = 15n3
+ n2
+ 4, T(n) = Ω
(n3
).
Proof.
Let c = 15 and n0 = 1.
Must show that 0 ≤ cg(n) and cg(n) ≤ f (n).
0 ≤ 15n3
for all n ≥ n0 = 1.
cg(n) = 15n3
≤ 15n3
+ n2
+ 4 = f (n)
8/10/2021
7
ASYMPTOTICS NOTATIONS
Θ-notation
Asymptotic tight bound
Θ (g(n)) represents a set of functions such that:
Θ (g(n)) = {f(n): there exist positive
constants c1, c2, and n0such
that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n)
for all n≥ n0 }
8/10/2021
8
Theta Example
f(N) = Θ(g(N)) iff f(N) = O(g(N)) and f(N) = Ω(g(N))
It can be read as “f(N) has order exactly g(N)”.
The growth rate of f(N) equals the growth rate of g(N). The
growth rate of f(N) is the same as the growth rate of g(N)
for large N.
Theta means the bound is the tightest possible.
If T(N) is a polynomial of degree k, T(N) = Θ(Nk
).
For logarithmic functions, T(logm N) = Θ(log N).
8/10/2021
9
o notation (Little oh)
The function f(n) = o(g(n)) iff
o(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  f(n) < cg(n)}.
Example: The function 3n + 2 = o(n2
) as
0
)
(
)
(
lim 


 n
g
n
f
n
0
2
3
lim 2




 n
n
n
8/10/2021
10
ω notation (Little omega)
The function f(n) = ω(g(n)) iff
w(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  cg(n) < f(n)}.
0
)
(
)
(
lim 


 n
f
n
g
n
8/10/2021
11
Asymptotic Notations
It is a way to compare “sizes” of functions
O-notation ------------------Less than equal to (“≤”)
Θ-notation ------------------Equal to (“=“)
Ω-notation ------------------Greater than equal to (“≥”)
O ≈ ≤
Ω ≈ ≥
Θ ≈ =
o ≈ <
ω ≈ >
8/10/2021
12
Examples On Asymptotic Notations
Explain How is f(x) = 4n^2 – 5n + 3 is O(n^2)
Show that
1) 30n+8 is O(n)
2) 100n + 5 ≠ (n2
)
3) 5n2
= (n)
4) 100n + 5 = O(n2
)
5) n2
/2 –n/2 = (n2
)
8/10/2021
13
Algorithm Design Techniques/Strategies
Brute force
Divide and conquer
Space and time tradeoffs
Greedy approach
Dynamic programming
Backtracking
Branch and bound
8/10/2021
14
Methods for Solving recurrences
 Substitution Method
We guess a bound and then use mathematical induction to prove our
guess correct.
Recursion Tree
Convert recurrence into tree
 Master Method
8/10/2021
15
Math You need to Review
8/10/2021
16
Substitution Method
8/10/2021
17
Quick Sort
8/10/2021
18
Binary Search
8/10/2021
19
Master Theorem
Master method provides a “cookbook” method for solving recurrences of the following form
T(n) = a T(n/b) + f(n)
where a  1, b > 1. If f(n) is asymptotically positive function. T(n) has following asymptotic
bounds:
There are 3 cases:
8/10/2021

More Related Content

PPT
Design and analysis of algorithm ppt ppt
PDF
Lecture3(b).pdf
PPTX
Asymptotic ssssssssssssssssssssssssssssss.pptx
PDF
Introduction to analysis algorithm in computer Science 2
PDF
asymptomatic notations and analysis in computer science
PPTX
02 asymptotic notations
PDF
02 CS316_algorithms_Asymptotic_Notations(2).pdf
PDF
Lecture 3(a) Asymptotic-analysis.pdf
Design and analysis of algorithm ppt ppt
Lecture3(b).pdf
Asymptotic ssssssssssssssssssssssssssssss.pptx
Introduction to analysis algorithm in computer Science 2
asymptomatic notations and analysis in computer science
02 asymptotic notations
02 CS316_algorithms_Asymptotic_Notations(2).pdf
Lecture 3(a) Asymptotic-analysis.pdf

Similar to Binary search design and ana algorithm.pptx (20)

PPTX
Asymptotic Notation
PPT
Time complexity
PPT
asymptotic notations i
PPTX
Asymptotic notation
PPT
Asymptotic notations
PDF
2. Asymptotic Notation- Analysis of Algorithms.pdf
PPT
Asymptotic notation
PPT
02 asymp
PDF
Unit-1 DAA_Notes.pdf
PPT
Asymptotic Notation and Complexity
PDF
asymptoticnotations-111102093214-phpapp01 (1).pdf
PPT
2-AnalysisOfAlgs.ppt
PPTX
2_Asymptotic notations.pptx
DOCX
PPTX
Asymptotic notation
PPTX
Analysis of algorithms
PPTX
Asymptotic notations
PDF
Asymptotic Growth of Functions
PPT
02-asymp.ppt01_Intro.ppt algorithm for preperation stu used
Asymptotic Notation
Time complexity
asymptotic notations i
Asymptotic notation
Asymptotic notations
2. Asymptotic Notation- Analysis of Algorithms.pdf
Asymptotic notation
02 asymp
Unit-1 DAA_Notes.pdf
Asymptotic Notation and Complexity
asymptoticnotations-111102093214-phpapp01 (1).pdf
2-AnalysisOfAlgs.ppt
2_Asymptotic notations.pptx
Asymptotic notation
Analysis of algorithms
Asymptotic notations
Asymptotic Growth of Functions
02-asymp.ppt01_Intro.ppt algorithm for preperation stu used
Ad

More from RajeshSukte1 (7)

PPTX
Towers of Hanoi Design and analysis of al.pptx
PPT
Introduction to Computer Graphics computer
PPT
Introduction to Computer Graphics elements
PPT
Unit I-cg.ppt Introduction to Computer Graphics elements
PPTX
UNIT-II - Social Development-part-1.2.pptx
PPTX
lecture5_4.pptx
PPT
PPS Java Overview Unit I.ppt
Towers of Hanoi Design and analysis of al.pptx
Introduction to Computer Graphics computer
Introduction to Computer Graphics elements
Unit I-cg.ppt Introduction to Computer Graphics elements
UNIT-II - Social Development-part-1.2.pptx
lecture5_4.pptx
PPS Java Overview Unit I.ppt
Ad

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Well-logging-methods_new................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Construction Project Organization Group 2.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
composite construction of structures.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Well-logging-methods_new................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
bas. eng. economics group 4 presentation 1.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Lecture Notes Electrical Wiring System Components
Model Code of Practice - Construction Work - 21102022 .pdf
Construction Project Organization Group 2.pptx
Internet of Things (IOT) - A guide to understanding
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Sustainable Sites - Green Building Construction
composite construction of structures.pdf
Operating System & Kernel Study Guide-1 - converted.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx

Binary search design and ana algorithm.pptx

  • 1. 1 ASYMPTOTICS NOTATIONS O-notation (Big Oh) Asymptotic Upper Bound For a given function g(n), we denote O(g(n)) as the set of functions: O(g(n)) = { f(n)| there exists positive constants c and n0 such that 0 ≤ f(n) ≤ c g(n) for all n ≥ n0 } It is used to represent the worst case growth of an algorithm in time or a data structure in space when they are dependent on n, where n is big enough Example : 8/10/2021
  • 2. 2 Big Oh - Example f(n) = n2 + 5n = O(n2) g(n) = n2 ……… c = 2 n n2 + 5n 2n2 1 5 2 2 14 8 5 50 50 f(n) <= c g(n) for all n> = n0 where c=2 & n0 =5 8/10/2021
  • 3. 3 Big Oh - Example Let f(N) = 2N2 . Then ◦ f(N) = O(N4 ) (loose bound) ◦ f(N) = O(N3 ) (loose bound) ◦ f(N) = O(N2 ) (It is the best answer and the bound is asymptotically tight.) O(N2 ): reads “order N-squared” or “Big-Oh N-squared”. 8/10/2021
  • 4. 4 Big Oh - Example Prove that if T(n) = 15n3 + n2 + 4, T(n) = O(n3 ). Proof. Let c = 20 and n0 = 1. Must show that 0 ≤ f (n) and f (n) ≤ cg(n). 0≤15n3 + n2 + 4 for all n ≥ n0 = 1. f (n) = 15n3 + n2 + 4 ≤ 20n3 (20g(n) = cg(n)) As per defination of Big O, hence T(n) = O(n3 ) 8/10/2021
  • 5. 5 ASYMPTOTICS NOTATIONS Ω-notation Asymptotic lower bound Ω (g(n)) represents a set of functions such that: Ω(g(n)) = {f(n): there exist positive constants c and n0 such that 0 ≤ c g(n) ≤ f(n) for all n≥ n0} 8/10/2021
  • 6. 6 Big Omega - Example Example 1 : f(n) = n2 + 5n g(n) = n2 ……… c = 1 n n2 + 5n c*n2 1 5 1 2 14 4 5 50 25 f(n) >= c g(n) for all n> = n0 where c=1 & n0 =1 Example 1 : Prove that if T(n) = 15n3 + n2 + 4, T(n) = Ω (n3 ). Proof. Let c = 15 and n0 = 1. Must show that 0 ≤ cg(n) and cg(n) ≤ f (n). 0 ≤ 15n3 for all n ≥ n0 = 1. cg(n) = 15n3 ≤ 15n3 + n2 + 4 = f (n) 8/10/2021
  • 7. 7 ASYMPTOTICS NOTATIONS Θ-notation Asymptotic tight bound Θ (g(n)) represents a set of functions such that: Θ (g(n)) = {f(n): there exist positive constants c1, c2, and n0such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n) for all n≥ n0 } 8/10/2021
  • 8. 8 Theta Example f(N) = Θ(g(N)) iff f(N) = O(g(N)) and f(N) = Ω(g(N)) It can be read as “f(N) has order exactly g(N)”. The growth rate of f(N) equals the growth rate of g(N). The growth rate of f(N) is the same as the growth rate of g(N) for large N. Theta means the bound is the tightest possible. If T(N) is a polynomial of degree k, T(N) = Θ(Nk ). For logarithmic functions, T(logm N) = Θ(log N). 8/10/2021
  • 9. 9 o notation (Little oh) The function f(n) = o(g(n)) iff o(g(n)) = {f(n):  c > 0,  n0 > 0 such that  n  n0, we have 0  f(n) < cg(n)}. Example: The function 3n + 2 = o(n2 ) as 0 ) ( ) ( lim     n g n f n 0 2 3 lim 2      n n n 8/10/2021
  • 10. 10 ω notation (Little omega) The function f(n) = ω(g(n)) iff w(g(n)) = {f(n):  c > 0,  n0 > 0 such that  n  n0, we have 0  cg(n) < f(n)}. 0 ) ( ) ( lim     n f n g n 8/10/2021
  • 11. 11 Asymptotic Notations It is a way to compare “sizes” of functions O-notation ------------------Less than equal to (“≤”) Θ-notation ------------------Equal to (“=“) Ω-notation ------------------Greater than equal to (“≥”) O ≈ ≤ Ω ≈ ≥ Θ ≈ = o ≈ < ω ≈ > 8/10/2021
  • 12. 12 Examples On Asymptotic Notations Explain How is f(x) = 4n^2 – 5n + 3 is O(n^2) Show that 1) 30n+8 is O(n) 2) 100n + 5 ≠ (n2 ) 3) 5n2 = (n) 4) 100n + 5 = O(n2 ) 5) n2 /2 –n/2 = (n2 ) 8/10/2021
  • 13. 13 Algorithm Design Techniques/Strategies Brute force Divide and conquer Space and time tradeoffs Greedy approach Dynamic programming Backtracking Branch and bound 8/10/2021
  • 14. 14 Methods for Solving recurrences  Substitution Method We guess a bound and then use mathematical induction to prove our guess correct. Recursion Tree Convert recurrence into tree  Master Method 8/10/2021
  • 15. 15 Math You need to Review 8/10/2021
  • 19. 19 Master Theorem Master method provides a “cookbook” method for solving recurrences of the following form T(n) = a T(n/b) + f(n) where a  1, b > 1. If f(n) is asymptotically positive function. T(n) has following asymptotic bounds: There are 3 cases: 8/10/2021