SlideShare a Scribd company logo
1 of 61
Time Complexity &
Order Of Growth
Analysis of Algorithm
• Efficiency of Algorithms
– Space Complexity
– Determination of the s[ace used by algorithm other
than its input size is known as space complexity
Analysis
– Time Complexity
The Time Complexity of an
Algorithm
Specifies how the running time depends
on the size of the input
3
Purpose
Purpose
• To estimate how long a program will run.
• To estimate the largest input that can reasonably be
given to the program.
• To compare the efficiency of different algorithms.
• To help focus on the parts of code that are executed
the largest number of times.
• To choose an algorithm for an application.
Purpose (Example)
• Suppose a machine that performs a million
floating-point operations per second (106 FLOPS),
then how long an algorithm will run for an input of
size n=50?
– 1) If the algorithm requires n2 such operations:
Purpose (Example)
• Suppose a machine that performs a million
floating-point operations per second (106 FLOPS),
then how long an algorithm will run for an input of
size n=50?
– 1) If the algorithm requires n2 such operations:
– 0.0025 second
Purpose (Example)
• Suppose a machine that performs a million floating-
point operations per second (106 FLOPS), then
how long an algorithm will run for an input of size
n=50?
– 1) If the algorithm requires n2 such operations:
– 0.0025 second
– 2) If the algorithm requires 2n such operations:
– A) Takes a similar amount of time (t < 1 sec)
– B) Takes a little bit longer time (1 sec < t < 1 year)
– C) Takes a much longer time (1 year < t)
Purpose (Example)
• Suppose a machine that performs a million
floating-point operations per second (106 FLOPS),
then how long an algorithm will run for an input of
size n=50?
– 1) If the algorithm requires n2 such operations:
– 0.0025 second
– 2) If the algorithm requires 2n such operations:
– over 35 years!
Time Complexity Is a Function
Specifies how the running time depends on
the size of the input.
A function mapping
“size” of input
“time” T(n) executed .
Definition of Time?
Definition of Time
• # of seconds (machine, implementation
dependent).
• # lines of code executed.
• # of times a specific operation is
performed (e.g., addition).
Theoretical analysis of time
efficiencyTime efficiency is analyzed by determining
the number of repetitions of the basic
operation as a function of input size
• Basic operation: the operation that
contributes most towards the running time
of the algorithm.
●
●
T(n) ≈ copC(n)
running time
execution time
for basic operation
Number of times
basic operation is
executed
input size
Input size and basic operation
examples
Problem Input size measure Basic operation
Search for key in a list of
n items
Multiply two matrices of
floating point numbers
Compute an
Graph problem
Input size and basic operation
examples
Problem Input size measure Basic operation
Search for key in a list of
n items
Number of items in the
list: n
Key comparison
Multiply two matrices of
floating point numbers
Compute an
Graph problem
Input size and basic operation
examples
Problem Input size measure Basic operation
Search for key in a list of
n items
Number of items in the
list: n
Key comparison
Multiply two matrices of
floating point numbers
Dimensions of matrices
Floating point
multiplication
Compute an
Graph problem
Input size and basic operation
examples
Problem Input size measure Basic operation
Search for key in list of
n items
Number of items in list n Key comparison
Multiply two matrices of
floating point numbers
Dimensions of matrices
Floating point
multiplication
Compute an n
Floating point
multiplication
Graph problem
Input size and basic operation
examples
Problem Input size measure Basic operation
Search for key in list of
n items
Number of items in list n Key comparison
Multiply two matrices of
floating point numbers
Dimensions of matrices
Floating point
multiplication
Compute an n
Floating point
multiplication
Graph problem #vertices and/or edges
Visiting a vertex or
traversing an edge
Time
Complexity
Every Case
Time
Complexity
Not Every
Case
Best Case
Worst Case
Average Case
Time Complexity
Every case Time Complexity
• For a given algorithm, T(n) is every case
time complexity if algorithm have to repeat
its basic operation every time for given
input size n. determination of T(n) is called
every case time complexity analysis.
Every case time
Complexity(examples)
• Sum of elements of array
Algorithm sum_array(A,n)
sum=0
for i=1 to n
sum+=A[i]
return sum
Every case time
Complexity(examples)
• Basic operation sum(adding up elements
of array
• Repeated how many number of times??
– For every element of array
• Complexity T(n)=O(n)
Every case time
Complexity(examples)
• Exchange Sort
Algorithm exchange_sort(A,n)
for i=1 to n-1
for j= i+1 to n
if A[i]>A[j]
exchange A[i] &A[j]
• Basic operation comparison of array
elements
• Repeated how many number of times??
• Complexity T(n)=n(n-1)/2=O(n^2)
Best Case Time Complexity
• For a given algorithm, B(n) is best case
time complexity if algorithm have to repeat
its basic operation for minimum time for
given input size n. determination of B(n) is
called Best case time complexity analysis.
Best Case Time Complexity
(Example)
Algorithm sequential_search(A,n,key)
i=0
while i<n && A[i]!= key
i=i+1
If i<n
return i
Else return-1
• Input size: number of elements in the
array i.e. n
• Basic operation :comparison of key with
array elements
• Best case: first element is the required key
Worst Case Time Complexity
• For a given algorithm, W(n) is worst case
time complexity if algorithm have to repeat
its basic operation for maximum number
of times for given input size n.
determination of W(n) is called worst case
time complexity analysis.
Sequential Search
• Input size: number of elements in the
array i.e. n
• Basic operation :comparison of key with
array elements
• worst case: last element is the required
key or key is not present in array at all
• Complexity :w(n)=O(n)
Average Case Time Complexity
• For a given algorithm, A(n) is average
case time complexity if algorithm have to
repeat its basic operation for average
number of times for given input size n.
determination of A(n) is called average
case time complexity analysis.
• Input size: number of elements in the
array i.e. n
• Basic operation :comparison of key with
array elements
• Average case: probability of successful
search is p(0<=p<=1)
• Probability of each element is p/n
multiplied with number of comparisons ie
• p/n*i
• A(n)=[1.p/n+2.p/n+…..n.p/n]+n.(1-p)
p/n(1+2+3+…+n)+n.(1-p)
P(n+1)/2 +n(1-p)
What is the order of growth?
In the running time expression, when n becomes large a term will
become significantly larger than the other ones:
this is the so-called dominant term
T1(n)=an+b
T2(n)=a log n+b
T3(n)=a n2+bn+c
T4(n)=an+b n +c
(a>1)
Dominant term: a n
Dominant term: a log n
Dominant term: a n2
Dominant term: an
What is the order of growth?
Order of growth
Linear
Logarithmic
Quadratic
Exponential
T’1(kn)= a kn=k T1(n)
T’2(kn)=a log(kn)=T2(n)+alog k
T’3(kn)=a (kn)2=k2 T3(n)
T’4(n)=akn=(an)k
How can be interpreted the order of growth?
• Between two algorithms it is considered that the one
having a smaller order of growth is more efficient
• However, this is true only for large enough input sizes
Example. Let us consider
T1(n)=10n+10 (linear order of growth)
T2(n)=n2 (quadratic order of growth)
If n<=10 then T1(n)>T2(n)
Thus the order of growth is relevant only for n>10
Growth Rate
0
50
100
150
200
250
300
FunctionValue
Data Size
Growth Rate of Diferent Functions
lg n
n lg n
n square
n cube
2 raise to
power n
Growth Rates
n lgn nlgn n2
n3
2n
0 #NUM! #NUM! 0 0 1
1 0 0 1 1 2
2 1 2 4 8 4
4 2 8 16 64 16
8 3 24 64 512 256
16 4 64 256 4096 65536
32 5 160 1024 32768 4.29E+09
64 6 384 4096 262144 1.84E+19
128 7 896 16384 2097152 3.4E+38
256 8 2048 65536 16777216 1.16E+77
512 9 4608 262144 1.34E+08 1.3E+154
1024 10 10240 1048576 1.07E+09
2048 11 22528 4194304 8.59E+09
Constant Factors
• The growth rate is not affected by
– constant factors or
– lower-order terms
• Examples
– 102n + 105 is a linear function
– 105n2 + 108n is a quadratic function
Asymptotic Notations
Order Notation
There may be a situation, e.g.
Tt
1 n
g(n)
f(n)
n0
f(n) <= g(n) for all n >= n0 Or
f(n) <= cg(n) for all n >= n0 and c = 1
g(n) is an asymptotic upper bound on f(n).
f(n) = O(g(n)) iff there exist two positive constants c and n0 such that
f(n) <= cg(n) for all n >= n0
Big –O Examples
choice of constant is not unique, for each different value of c there is
corresponding value of no that satisfies basic relationship.
Big-O Example
More Big-Oh Examples
7n-2
7n-2 is O(n)
need c > 0 and n0 ≥ 1 such that 7n-2 ≤ c•n for n ≥ n0
this is true for c = 7 and n0 = 1
 3n3 + 20n2 + 5
3n3 + 20n2 + 5 is O(n3)
need c > 0 and n0 ≥ 1 such that 3n3 + 20n2 + 5 ≤ c•n3 for n ≥ n0
this is true for c = 28 and n0 = 1
 3 log n + log log n
3 log n + log log n is O(log n)
need c > 0 and n0 ≥ 1 such that 3 log n + log log n ≤ c•log n for n ≥ n0
this is true for c = 4 and n0 = 2
Big-Oh and Growth Rate
• The big-Oh notation gives an upper bound on the
growth rate of a function
• The statement “f(n) is O(g(n))” means that the growth
rate of f(n) is no more than the growth rate of g(n)
• We can use the big-Oh notation to rank functions
according to their growth rate
f(n) is O(g(n)) g(n) is O(f(n))
g(n) grows more Yes No
f(n) grows more No Yes
Same growth Yes Yes
Big-Oh Example
• Example: the function
n2 is not O(n)
– n2 ≤ cn
– n ≤ c
– The above inequality
cannot be satisfied
since c must be a
constant
1
10
100
1,000
10,000
100,000
1,000,000
1 10 100 1,000
n
n^ 2 100n
10n n
Big-Oh Rules
• If is f(n) a polynomial of degree d, then f(n) is
O(nd), i.e.,
1.Drop lower-order terms
2.Drop constant factors
• Use the smallest possible class of functions
–.Say “2n is O(n)” instead of “2n is O(n2)”
• Use the simplest expression of the class
–.Say “3n + 5 is O(n)” instead of “3n + 5 is O(3n)”
Order Notation
Asymptotic Lower Bound:f(n) = Ω(g(n)),
iff there exit positive constants c and n0 such that
f(n) >= cg(n) for all n >= n0
nn0
f(n)
g(n)
Big Ω Examples
Big Ω Examples
Big-Omega Notation
• Given functions f(n) and g(n), we say that f(n) is
Ω(g(n)) if there are positive constants
c and n0 such that
f(n) >=cg(n) for n ≥ n0
• Example:
, let c=1/12, n=1
Order Notation
Asymptotically Tight Bound: f(n) = θ(g(n)),
iff there exit positive constants c1 and c2 and n0 such that
c1 g(n) <= f(n) <= c2g(n) for all n >= n0
nn0
c2g(n)
c1g(n)
f(n)
This means that the best and worst case requires the same
amount of time to within a constant factor.
Θ -Examples
Intuition for Asymptotic
Notation
Big-Oh
f(n) is O(g(n)) if f(n) is asymptotically less than or equal to g(n)
big-Omega
f(n) is Ω(g(n)) if f(n) is asymptotically greater than or equal to g(n)
big-Theta
f(n) is Θ(g(n)) if f(n) is asymptotically equal to g(n)
Small ‘o’ Notation:
For every c and n if f(n) is always less than g(n) then f(n) belongs to o(g(n)).
Small Omega Notation:
For every c and n if f(n) is always above than g(n) then f(n) belongs to small
omega(g(n)).
Relatives of Big-O
Using Limits for Comparing
Order of Growth
Small-O Examples
Small-Ω
Big-O
Big-Ω
Θ Examples
02 order of growth

More Related Content

What's hot

Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Specification and complexity - algorithm
Specification and complexity - algorithmSpecification and complexity - algorithm
Specification and complexity - algorithmBipul Roy Bpl
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data StructureJeanie Arnoco
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionPHI Learning Pvt. Ltd.
 
I. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmI. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmvikas dhakane
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSGokul Hari
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingR Islam
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmHema Kashyap
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search StrategiesAmey Kerkar
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sortDistrict Administration
 

What's hot (20)

Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Specification and complexity - algorithm
Specification and complexity - algorithmSpecification and complexity - algorithm
Specification and complexity - algorithm
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third Edition
 
I. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmI. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithm
 
Apriori algorithm
Apriori algorithmApriori algorithm
Apriori algorithm
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sort
 

Viewers also liked

Analysis of algorithn class 2
Analysis of algorithn class 2Analysis of algorithn class 2
Analysis of algorithn class 2Kumar
 
03 mathematical anaylsis
03 mathematical anaylsis03 mathematical anaylsis
03 mathematical anaylsisHira Gul
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notationsjayavignesh86
 
Time complexity (linear search vs binary search)
Time complexity (linear search vs binary search)Time complexity (linear search vs binary search)
Time complexity (linear search vs binary search)Kumar
 
Introduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic NotationIntroduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic NotationAmrinder Arora
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsSwapnil Agrawal
 
pseudo code basics
pseudo code basicspseudo code basics
pseudo code basicsSabik T S
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codeshermiraguilar
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 
Growth & development presentation
Growth & development presentationGrowth & development presentation
Growth & development presentationHazel Garin
 

Viewers also liked (14)

Analysis of algorithn class 2
Analysis of algorithn class 2Analysis of algorithn class 2
Analysis of algorithn class 2
 
Sorting
SortingSorting
Sorting
 
03 mathematical anaylsis
03 mathematical anaylsis03 mathematical anaylsis
03 mathematical anaylsis
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notations
 
Time complexity (linear search vs binary search)
Time complexity (linear search vs binary search)Time complexity (linear search vs binary search)
Time complexity (linear search vs binary search)
 
Introduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic NotationIntroduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic Notation
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Relations in Discrete Math
Relations in Discrete MathRelations in Discrete Math
Relations in Discrete Math
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
 
pseudo code basics
pseudo code basicspseudo code basics
pseudo code basics
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Growth & development presentation
Growth & development presentationGrowth & development presentation
Growth & development presentation
 

Similar to 02 order of growth

Ch1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdfCh1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdfzoric99
 
algorithmanalysis and effciency.pptx
algorithmanalysis and effciency.pptxalgorithmanalysis and effciency.pptx
algorithmanalysis and effciency.pptxChSreenivasuluReddy
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2chidabdu
 
Data Structure & Algorithms - Introduction
Data Structure & Algorithms - IntroductionData Structure & Algorithms - Introduction
Data Structure & Algorithms - Introductionbabuk110
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsKrishnan MuthuManickam
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematicalbabuk110
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithmDevaKumari Vijay
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsiqbalphy1
 
Analysis and Algorithms: basic Introduction
Analysis and Algorithms: basic IntroductionAnalysis and Algorithms: basic Introduction
Analysis and Algorithms: basic Introductionssuseraf8b2f
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and NotationsAbid Kohistani
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisAnindita Kundu
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexityAnaya Zafar
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsAbdullah Al-hazmy
 

Similar to 02 order of growth (20)

Ch1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdfCh1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdf
 
algorithmanalysis and effciency.pptx
algorithmanalysis and effciency.pptxalgorithmanalysis and effciency.pptx
algorithmanalysis and effciency.pptx
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
Data Structure & Algorithms - Introduction
Data Structure & Algorithms - IntroductionData Structure & Algorithms - Introduction
Data Structure & Algorithms - Introduction
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of Algorithms
 
Algorithms
Algorithms Algorithms
Algorithms
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
 
Chapter two
Chapter twoChapter two
Chapter two
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Analysis and Algorithms: basic Introduction
Analysis and Algorithms: basic IntroductionAnalysis and Algorithms: basic Introduction
Analysis and Algorithms: basic Introduction
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysis
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
 
Annotations.pdf
Annotations.pdfAnnotations.pdf
Annotations.pdf
 

More from Hira Gul

Final iwvc
Final iwvcFinal iwvc
Final iwvcHira Gul
 
Oerating system project
Oerating system projectOerating system project
Oerating system projectHira Gul
 
project Judaism iwvc presentation
project Judaism iwvc presentation project Judaism iwvc presentation
project Judaism iwvc presentation Hira Gul
 
09d transform & conquer spring2015
09d transform & conquer spring201509d transform & conquer spring2015
09d transform & conquer spring2015Hira Gul
 
08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15Hira Gul
 
04 brute force
04 brute force04 brute force
04 brute forceHira Gul
 
01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015Hira Gul
 

More from Hira Gul (11)

Final iwvc
Final iwvcFinal iwvc
Final iwvc
 
Oerating system project
Oerating system projectOerating system project
Oerating system project
 
project Judaism iwvc presentation
project Judaism iwvc presentation project Judaism iwvc presentation
project Judaism iwvc presentation
 
09d transform & conquer spring2015
09d transform & conquer spring201509d transform & conquer spring2015
09d transform & conquer spring2015
 
08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15
 
07 dc3
07 dc307 dc3
07 dc3
 
06 dc2
06 dc206 dc2
06 dc2
 
05 dc1
05 dc105 dc1
05 dc1
 
04 brute force
04 brute force04 brute force
04 brute force
 
03 dc
03 dc03 dc
03 dc
 
01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 

02 order of growth

  • 1. Time Complexity & Order Of Growth Analysis of Algorithm
  • 2. • Efficiency of Algorithms – Space Complexity – Determination of the s[ace used by algorithm other than its input size is known as space complexity Analysis – Time Complexity
  • 3. The Time Complexity of an Algorithm Specifies how the running time depends on the size of the input 3
  • 5. Purpose • To estimate how long a program will run. • To estimate the largest input that can reasonably be given to the program. • To compare the efficiency of different algorithms. • To help focus on the parts of code that are executed the largest number of times. • To choose an algorithm for an application.
  • 6. Purpose (Example) • Suppose a machine that performs a million floating-point operations per second (106 FLOPS), then how long an algorithm will run for an input of size n=50? – 1) If the algorithm requires n2 such operations:
  • 7. Purpose (Example) • Suppose a machine that performs a million floating-point operations per second (106 FLOPS), then how long an algorithm will run for an input of size n=50? – 1) If the algorithm requires n2 such operations: – 0.0025 second
  • 8. Purpose (Example) • Suppose a machine that performs a million floating- point operations per second (106 FLOPS), then how long an algorithm will run for an input of size n=50? – 1) If the algorithm requires n2 such operations: – 0.0025 second – 2) If the algorithm requires 2n such operations: – A) Takes a similar amount of time (t < 1 sec) – B) Takes a little bit longer time (1 sec < t < 1 year) – C) Takes a much longer time (1 year < t)
  • 9. Purpose (Example) • Suppose a machine that performs a million floating-point operations per second (106 FLOPS), then how long an algorithm will run for an input of size n=50? – 1) If the algorithm requires n2 such operations: – 0.0025 second – 2) If the algorithm requires 2n such operations: – over 35 years!
  • 10. Time Complexity Is a Function Specifies how the running time depends on the size of the input. A function mapping “size” of input “time” T(n) executed .
  • 12. Definition of Time • # of seconds (machine, implementation dependent). • # lines of code executed. • # of times a specific operation is performed (e.g., addition).
  • 13. Theoretical analysis of time efficiencyTime efficiency is analyzed by determining the number of repetitions of the basic operation as a function of input size • Basic operation: the operation that contributes most towards the running time of the algorithm. ● ● T(n) ≈ copC(n) running time execution time for basic operation Number of times basic operation is executed input size
  • 14. Input size and basic operation examples Problem Input size measure Basic operation Search for key in a list of n items Multiply two matrices of floating point numbers Compute an Graph problem
  • 15. Input size and basic operation examples Problem Input size measure Basic operation Search for key in a list of n items Number of items in the list: n Key comparison Multiply two matrices of floating point numbers Compute an Graph problem
  • 16. Input size and basic operation examples Problem Input size measure Basic operation Search for key in a list of n items Number of items in the list: n Key comparison Multiply two matrices of floating point numbers Dimensions of matrices Floating point multiplication Compute an Graph problem
  • 17. Input size and basic operation examples Problem Input size measure Basic operation Search for key in list of n items Number of items in list n Key comparison Multiply two matrices of floating point numbers Dimensions of matrices Floating point multiplication Compute an n Floating point multiplication Graph problem
  • 18. Input size and basic operation examples Problem Input size measure Basic operation Search for key in list of n items Number of items in list n Key comparison Multiply two matrices of floating point numbers Dimensions of matrices Floating point multiplication Compute an n Floating point multiplication Graph problem #vertices and/or edges Visiting a vertex or traversing an edge
  • 19. Time Complexity Every Case Time Complexity Not Every Case Best Case Worst Case Average Case Time Complexity
  • 20. Every case Time Complexity • For a given algorithm, T(n) is every case time complexity if algorithm have to repeat its basic operation every time for given input size n. determination of T(n) is called every case time complexity analysis.
  • 21. Every case time Complexity(examples) • Sum of elements of array Algorithm sum_array(A,n) sum=0 for i=1 to n sum+=A[i] return sum
  • 22. Every case time Complexity(examples) • Basic operation sum(adding up elements of array • Repeated how many number of times?? – For every element of array • Complexity T(n)=O(n)
  • 23. Every case time Complexity(examples) • Exchange Sort Algorithm exchange_sort(A,n) for i=1 to n-1 for j= i+1 to n if A[i]>A[j] exchange A[i] &A[j]
  • 24. • Basic operation comparison of array elements • Repeated how many number of times?? • Complexity T(n)=n(n-1)/2=O(n^2)
  • 25. Best Case Time Complexity • For a given algorithm, B(n) is best case time complexity if algorithm have to repeat its basic operation for minimum time for given input size n. determination of B(n) is called Best case time complexity analysis.
  • 26. Best Case Time Complexity (Example) Algorithm sequential_search(A,n,key) i=0 while i<n && A[i]!= key i=i+1 If i<n return i Else return-1
  • 27. • Input size: number of elements in the array i.e. n • Basic operation :comparison of key with array elements • Best case: first element is the required key
  • 28. Worst Case Time Complexity • For a given algorithm, W(n) is worst case time complexity if algorithm have to repeat its basic operation for maximum number of times for given input size n. determination of W(n) is called worst case time complexity analysis.
  • 29. Sequential Search • Input size: number of elements in the array i.e. n • Basic operation :comparison of key with array elements • worst case: last element is the required key or key is not present in array at all • Complexity :w(n)=O(n)
  • 30. Average Case Time Complexity • For a given algorithm, A(n) is average case time complexity if algorithm have to repeat its basic operation for average number of times for given input size n. determination of A(n) is called average case time complexity analysis.
  • 31. • Input size: number of elements in the array i.e. n • Basic operation :comparison of key with array elements
  • 32. • Average case: probability of successful search is p(0<=p<=1) • Probability of each element is p/n multiplied with number of comparisons ie • p/n*i • A(n)=[1.p/n+2.p/n+…..n.p/n]+n.(1-p) p/n(1+2+3+…+n)+n.(1-p) P(n+1)/2 +n(1-p)
  • 33. What is the order of growth? In the running time expression, when n becomes large a term will become significantly larger than the other ones: this is the so-called dominant term T1(n)=an+b T2(n)=a log n+b T3(n)=a n2+bn+c T4(n)=an+b n +c (a>1) Dominant term: a n Dominant term: a log n Dominant term: a n2 Dominant term: an
  • 34. What is the order of growth? Order of growth Linear Logarithmic Quadratic Exponential T’1(kn)= a kn=k T1(n) T’2(kn)=a log(kn)=T2(n)+alog k T’3(kn)=a (kn)2=k2 T3(n) T’4(n)=akn=(an)k
  • 35. How can be interpreted the order of growth? • Between two algorithms it is considered that the one having a smaller order of growth is more efficient • However, this is true only for large enough input sizes Example. Let us consider T1(n)=10n+10 (linear order of growth) T2(n)=n2 (quadratic order of growth) If n<=10 then T1(n)>T2(n) Thus the order of growth is relevant only for n>10
  • 36. Growth Rate 0 50 100 150 200 250 300 FunctionValue Data Size Growth Rate of Diferent Functions lg n n lg n n square n cube 2 raise to power n
  • 37. Growth Rates n lgn nlgn n2 n3 2n 0 #NUM! #NUM! 0 0 1 1 0 0 1 1 2 2 1 2 4 8 4 4 2 8 16 64 16 8 3 24 64 512 256 16 4 64 256 4096 65536 32 5 160 1024 32768 4.29E+09 64 6 384 4096 262144 1.84E+19 128 7 896 16384 2097152 3.4E+38 256 8 2048 65536 16777216 1.16E+77 512 9 4608 262144 1.34E+08 1.3E+154 1024 10 10240 1048576 1.07E+09 2048 11 22528 4194304 8.59E+09
  • 38. Constant Factors • The growth rate is not affected by – constant factors or – lower-order terms • Examples – 102n + 105 is a linear function – 105n2 + 108n is a quadratic function
  • 40. Order Notation There may be a situation, e.g. Tt 1 n g(n) f(n) n0 f(n) <= g(n) for all n >= n0 Or f(n) <= cg(n) for all n >= n0 and c = 1 g(n) is an asymptotic upper bound on f(n). f(n) = O(g(n)) iff there exist two positive constants c and n0 such that f(n) <= cg(n) for all n >= n0
  • 41. Big –O Examples choice of constant is not unique, for each different value of c there is corresponding value of no that satisfies basic relationship.
  • 43. More Big-Oh Examples 7n-2 7n-2 is O(n) need c > 0 and n0 ≥ 1 such that 7n-2 ≤ c•n for n ≥ n0 this is true for c = 7 and n0 = 1  3n3 + 20n2 + 5 3n3 + 20n2 + 5 is O(n3) need c > 0 and n0 ≥ 1 such that 3n3 + 20n2 + 5 ≤ c•n3 for n ≥ n0 this is true for c = 28 and n0 = 1  3 log n + log log n 3 log n + log log n is O(log n) need c > 0 and n0 ≥ 1 such that 3 log n + log log n ≤ c•log n for n ≥ n0 this is true for c = 4 and n0 = 2
  • 44. Big-Oh and Growth Rate • The big-Oh notation gives an upper bound on the growth rate of a function • The statement “f(n) is O(g(n))” means that the growth rate of f(n) is no more than the growth rate of g(n) • We can use the big-Oh notation to rank functions according to their growth rate f(n) is O(g(n)) g(n) is O(f(n)) g(n) grows more Yes No f(n) grows more No Yes Same growth Yes Yes
  • 45. Big-Oh Example • Example: the function n2 is not O(n) – n2 ≤ cn – n ≤ c – The above inequality cannot be satisfied since c must be a constant 1 10 100 1,000 10,000 100,000 1,000,000 1 10 100 1,000 n n^ 2 100n 10n n
  • 46. Big-Oh Rules • If is f(n) a polynomial of degree d, then f(n) is O(nd), i.e., 1.Drop lower-order terms 2.Drop constant factors • Use the smallest possible class of functions –.Say “2n is O(n)” instead of “2n is O(n2)” • Use the simplest expression of the class –.Say “3n + 5 is O(n)” instead of “3n + 5 is O(3n)”
  • 47. Order Notation Asymptotic Lower Bound:f(n) = Ω(g(n)), iff there exit positive constants c and n0 such that f(n) >= cg(n) for all n >= n0 nn0 f(n) g(n)
  • 50. Big-Omega Notation • Given functions f(n) and g(n), we say that f(n) is Ω(g(n)) if there are positive constants c and n0 such that f(n) >=cg(n) for n ≥ n0 • Example: , let c=1/12, n=1
  • 51. Order Notation Asymptotically Tight Bound: f(n) = θ(g(n)), iff there exit positive constants c1 and c2 and n0 such that c1 g(n) <= f(n) <= c2g(n) for all n >= n0 nn0 c2g(n) c1g(n) f(n) This means that the best and worst case requires the same amount of time to within a constant factor.
  • 53. Intuition for Asymptotic Notation Big-Oh f(n) is O(g(n)) if f(n) is asymptotically less than or equal to g(n) big-Omega f(n) is Ω(g(n)) if f(n) is asymptotically greater than or equal to g(n) big-Theta f(n) is Θ(g(n)) if f(n) is asymptotically equal to g(n)
  • 54. Small ‘o’ Notation: For every c and n if f(n) is always less than g(n) then f(n) belongs to o(g(n)). Small Omega Notation: For every c and n if f(n) is always above than g(n) then f(n) belongs to small omega(g(n)). Relatives of Big-O
  • 55. Using Limits for Comparing Order of Growth
  • 58. Big-O

Editor's Notes

  1. &amp;lt;number&amp;gt;
  2. &amp;lt;number&amp;gt;
  3. &amp;lt;number&amp;gt;
  4. &amp;lt;number&amp;gt;
  5. &amp;lt;number&amp;gt;
  6. &amp;lt;number&amp;gt;
  7. &amp;lt;number&amp;gt;
  8. &amp;lt;number&amp;gt;
  9. &amp;lt;number&amp;gt;
  10. &amp;lt;number&amp;gt;
  11. &amp;lt;number&amp;gt;
  12. &amp;lt;number&amp;gt; regarding an point out that the input size measure is more properly measured by number of bits: b= ⌊log2 n⌋ + 1 Graph problems are mentioned here just to give me an opportunity to discuss them in general. Typically this will depend on graph representation and the specific problem.
  13. &amp;lt;number&amp;gt;
  14. &amp;lt;number&amp;gt;
  15. &amp;lt;number&amp;gt;
  16. &amp;lt;number&amp;gt;
  17. &amp;lt;number&amp;gt;
  18. Definition: A curve representing the limit of a function. That is, the distance between a function and the curve tends to zero. The function may or may not intersect the bounding curve. Asymptotic upper bound:An asymptotic bound, as function of the size of the input, on the worst (slowest, most amount of space used, etc.) an algorithm will do to solve a problem. That is, no input will cause the algorithm to use more resources than the bound. &amp;lt;number&amp;gt;
  19. &amp;lt;number&amp;gt;