SlideShare a Scribd company logo
Analysis and Design of Algorithms
Part 1 Basics of Algorithm
1. Introduction
2. Characteristics
3. Use of Algorithms
Analysis and Design of Algorithms 2
1. Introduction
I. The word Algorithm come from the name of 9th century Persian mathematician
Al-Khwārizmī, Whose work built upon the work of 7th century Indian
mathematician Brahmagupta.
II. Ada Lovelace invented 1st Algorithm !
III. An Algorithm is any well-defined computational procedure that takes some
value or set of values, as input and produces some value or set of values as
output.
IV. The Internet enables people all around the world to quickly access and retrieve
large amount of information. In order to do so, clever algorithms are employed
to manage and manipulate this large volume of data. Example of that is,
finding good routes on which the data will travel.
Analysis and Design of Algorithms 3
o If all Algorithms are performing same procedure, all of them are
equal and if not then what differentiates them?
1. Correctness of Algorithm
I. Produce correct answer always.
II. If it is taking lot of time and
resources, We build our
algorithms as to give the best
possible answer.
2. Efficiency of Algorithm
I. Time it takes
II. Complexity
III. Space requirement
Analysis and Design of Algorithms 4
2. Characteristics
• Modularity
• Correctness
• Maintainability
• Functionality
• Robustness
• User-friendliness
• Simplicity
• Programmer time
• Extensibility
• Reliability
Analysis and Design of Algorithms 5
3. Use of Algorithms
I. Algorithms help us to understand scalability.
II. Public-key cryptography and digital signatures are among the core
technologies used and are based on numerical algorithms.
III. Algorithmic mathematics provides a language for talking about
program behaviour.
IV. Speed is fun!
V. Local-area and wide-area networking.
Analysis and Design of Algorithms 6
Part 2 Analysis of Algorithms
1. Overview
2. Time Base Analysis
3. Space Base Analysis
4. Three Cases
Analysis and Design of Algorithms 7
Figure : Types of analysis
Analysis and Design of Algorithms 8
Analysis
Time Complexity Space Complexity
1. Time Complexity
I. In computer science, the time complexity of an algorithm
quantifies the amount of time taken by an algorithm to run as
a function of the length of the string representing the input.
II. The time complexity of an algorithm is commonly expressed
using big O notation, which excludes coefficients and lower
order terms.
Analysis and Design of Algorithms 9
2. Space Complexity
I. Space complexity is a measure of the amount of working
storage an algorithm needs. That means how much memory,
in the worst case, is needed at any point in the algorithm.
II. As with time complexity, we're mostly concerned with how the
space needs grow, in big-Oh terms, as the size N of the input
problem grows.
Analysis and Design of Algorithms 10
To find Time Complexity of a program
Analysis and Design of Algorithms 11
Cost
sum = 0; c1
for(i=0; i<N; i++) c2
for(j=0; j<N; j++) c2
sum += arr[i][j]; c3
------------
c1 + c2 x (N+1) + c2 x N x (N+1) + c3 x N2
Three Cases
1. Best Case
2. Average Case
3. Worst Case
Analysis and Design of Algorithms 12
1. Best case
I. Cheat with a slow algorithm that works fast on some input
II. Provides a lower bound on running time
III. Input is the one for which the algorithm runs the fastest
Analysis and Design of Algorithms 13
Lower Bound RunningTime Upper Bound 
2. Average case
I. T(n) = expected time of algorithm over all inputs of size n.
II. Need assumption of statistical distribution of inputs.
III. Provides a prediction about the running time.
IV. Assumes that the input is random.
Analysis and Design of Algorithms 14
3. Worst case
I. T(n) = maximum time of algorithm on any input of size n.
II. Provides an upper bound on running time.
III. An absolute guarantee that the algorithm would not run
longer, no matter what the inputs are.
Analysis and Design of Algorithms 15
Analysis of INSERTION sort
16
1]1[8
)1(17
)1(][]1[6
][05
114
10]11[sequence
sortedtheinto][Insert3
1][2
][21
timescostSORT(A)-INSERTION
8
27
26
25
4
2
1















nckeyiA
tcii
tciAiA
tckeyiAandi
ncji
njA
jA
ncjAkey
ncAlengthj
n
j j
n
j j
n
j j
do
while
do
tofor
Analysis and Design of Algorithms
Analysis of INSERTION sort
I. Total Running Time
II. Best Case: The array is already sorted (tj =1 for j=2,3, ...,n)
17
)1()1()1()(
2
6
2
5421  

n
j
j
n
j
j tctcncnccnT ).1()1( 8
2
7  

nctc
n
j
j
)1()1()1()1()( 85421  ncncncncncnT
).()( 854285421 ccccnccccc 
Analysis and Design of Algorithms
Analysis of INSERTION sort
• Worst Case: The array is reverse sorted (tj =j for j=2,3, ...,n)
18
)12/)1(()1()( 521  nncncncnT
)1()2/)1(()2/)1(( 876  ncnncnnc
ncccccccnccc )2/2/2/()2/2/2/( 8765421
2
765 
2
)1(
1



nn
j
n
j
cbnannT  2
)(
Analysis and Design of Algorithms
Part 3 Asymptotic Notation
1. Big-O Notation - ⃝
2. Theta Notation - Ө
3. Omega Notation - Ω
4. Example
Analysis and Design of Algorithms 19
Analysis and Design of Algorithms 20
1. Big-O Notation
For a given function g(n), we denote by O(g(n)) the set of functions.
The above statement implies that if, f(n)=O(g(n)) then F(n) is always
We use the O-notation to give an asymptotic upper bound of a
function, to within a constant factor.
)(ncg








0
0
allfor)()(0
s.t.andconstantspositiveexistthere:)(
))((
nnncgnf
ncnf
ngO
Analysis and Design of Algorithms 21
2. Ω-Omega Notation
I. For a given function , ,we denote by the set of
functions.
II. The above statement implies that, if f(n)=O(g(n)) then F(n) is
always
III. We use Ω-notation to give an asymptotic lower bound on a
function, to within a constant factor.
Analysis and Design of Algorithms 22
)(ng ))(( ng
)(ncg








0
0
allfor)()(0
s.t.andconstantspositiveexistthere:)(
))((
nnnfncg
ncnf
ng
Analysis and Design of Algorithms 23
3. Ө-Theta Notation
• For a given function , we denote by the set of
functions
• A function belongs to the set if there exist positive
constants c1 and c2 such that it can be “sand- wiched” between
and
• The above statement implies that, if f(n)=O(g(n)) then F(n) is always
Analysis and Design of Algorithms 24
)(ng ))(( ng








021
021
allfor)()()(c0
s.t.and,,constantspositiveexistthere:)(
))((
nnngcnfng
nccnf
ng
)(nf ))(( ng
)(1 ngc
)(2 ngc
)()()( 21 ngcnfngc 
Analysis and Design of Algorithms 25
26
Examples (Big-O)
•30n+8=O(n).
•30n+8  cn, n>n0 .
•Let c=31, n0=8. Assume n>n0=8. Then
cn = 31n = 30n + n > 30n+8, so 30n+8 < cn.
Analysis and Design of Algorithms
27
• Note 30n+8 isn’t
less than n
anywhere (n>0).
• But it is less than
31n everywhere to
the right of n=8.
n>n0=8 
Big-O example, graphically
Increasing n 
Valueoffunction
n
30n+8
cn =
31n
30n+8
O(n)
Analysis and Design of Algorithms
28
• Subset relations between order-of-growth sets.
Relations Between Different Sets
RR
( f )O( f )
( f )
• f
Analysis and Design of Algorithms
Thank you.
Analysis and Design of Algorithms 29

More Related Content

What's hot (19)

PPT
Problem solving
hamza239523
 
PPTX
#1 designandanalysis of algo
Brijida Charizma Ardoña-Navarro
 
PDF
Daa notes 1
smruti sarangi
 
PDF
Fundamentals of algorithms
Amit Kumar Rathi
 
PPSX
Ds03 algorithms jyoti lakhani
jyoti_lakhani
 
PDF
01 Analysis of Algorithms: Introduction
Andres Mendez-Vazquez
 
PPTX
Daa unit 1
Abhimanyu Mishra
 
PDF
Lecture 2 role of algorithms in computing
jayavignesh86
 
PPTX
Design and analysis of algorithms - Abstract View
Waqas Nawaz
 
PPT
Algorithm Design Presentation
Kawsar Ahmed
 
PPT
Aad introduction
Mr SMAK
 
PPT
Design and Analysis of Algorithms
Swapnil Agrawal
 
PPT
Slide1
Thiti Sununta
 
PDF
Daa notes 2
smruti sarangi
 
PPTX
Daa unit 5
Abhimanyu Mishra
 
PPT
Daa presentation 97
Garima Verma
 
PPTX
Introduction to dynamic programming
Amisha Narsingani
 
PPT
Lecture 8 dynamic programming
Oye Tu
 
Problem solving
hamza239523
 
#1 designandanalysis of algo
Brijida Charizma Ardoña-Navarro
 
Daa notes 1
smruti sarangi
 
Fundamentals of algorithms
Amit Kumar Rathi
 
Ds03 algorithms jyoti lakhani
jyoti_lakhani
 
01 Analysis of Algorithms: Introduction
Andres Mendez-Vazquez
 
Daa unit 1
Abhimanyu Mishra
 
Lecture 2 role of algorithms in computing
jayavignesh86
 
Design and analysis of algorithms - Abstract View
Waqas Nawaz
 
Algorithm Design Presentation
Kawsar Ahmed
 
Aad introduction
Mr SMAK
 
Design and Analysis of Algorithms
Swapnil Agrawal
 
Daa notes 2
smruti sarangi
 
Daa unit 5
Abhimanyu Mishra
 
Daa presentation 97
Garima Verma
 
Introduction to dynamic programming
Amisha Narsingani
 
Lecture 8 dynamic programming
Oye Tu
 

Viewers also liked (19)

PPTX
Recurrence relationclass 5
Kumar
 
PPTX
Big o notation
hamza mushtaq
 
PDF
01. design & analysis of agorithm intro & complexity analysis
Onkar Nath Sharma
 
PPT
Sets and disjoint sets union123
Ankita Goyal
 
PDF
02 Notes Divide and Conquer
Andres Mendez-Vazquez
 
PPTX
Algorithm Introduction
Ashim Lamichhane
 
PPTX
Algorithm Design and Complexity - Course 1&2
Traian Rebedea
 
PPTX
Radix 4 FFT algorithm and it time complexity computation
Raj Jaiswal
 
PDF
Karmarkar's Algorithm For Linear Programming Problem
Ajay Dhamija
 
PPTX
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Amrinder Arora
 
PPTX
Asymptotic Notations
Rishabh Soni
 
PPT
Complexity of Algorithm
Muhammad Muzammal
 
DOC
Time and space complexity
Ankit Katiyar
 
PPTX
Divide and Conquer - Part 1
Amrinder Arora
 
PPTX
Algorithm analysis (All in one)
jehan1987
 
PPT
Gestational diabetes
Ayub Medical College
 
PPT
Normal labor-and-delivery by Dr syed khawar
Ayub Medical College
 
PDF
Marcella Marletta - Workshop "Il governo dell'innovazione farmaceutica" - Rom...
Marcella Marletta
 
Recurrence relationclass 5
Kumar
 
Big o notation
hamza mushtaq
 
01. design & analysis of agorithm intro & complexity analysis
Onkar Nath Sharma
 
Sets and disjoint sets union123
Ankita Goyal
 
02 Notes Divide and Conquer
Andres Mendez-Vazquez
 
Algorithm Introduction
Ashim Lamichhane
 
Algorithm Design and Complexity - Course 1&2
Traian Rebedea
 
Radix 4 FFT algorithm and it time complexity computation
Raj Jaiswal
 
Karmarkar's Algorithm For Linear Programming Problem
Ajay Dhamija
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Amrinder Arora
 
Asymptotic Notations
Rishabh Soni
 
Complexity of Algorithm
Muhammad Muzammal
 
Time and space complexity
Ankit Katiyar
 
Divide and Conquer - Part 1
Amrinder Arora
 
Algorithm analysis (All in one)
jehan1987
 
Gestational diabetes
Ayub Medical College
 
Normal labor-and-delivery by Dr syed khawar
Ayub Medical College
 
Marcella Marletta - Workshop "Il governo dell'innovazione farmaceutica" - Rom...
Marcella Marletta
 
Ad

Similar to Algorithms : Introduction and Analysis (20)

PDF
CCS 3102 Lecture 3_ Complexity theory.pdf
JosephKariuki46
 
PPTX
AoA Lec Design of algorithm spresentation
HamzaSadaat
 
PPTX
Unit ii algorithm
Tribhuvan University
 
PPT
Algorithm in Computer, Sorting and Notations
Abid Kohistani
 
PPTX
algorithmanalysisinfundamentalsofdatastructure-190810085243.pptx
ShirishaBuduputi
 
PPT
Chapter1.1 Introduction.ppt
Tekle12
 
PPT
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Tekle12
 
PDF
Analysis of Algorithms
Amna Saeed
 
PPTX
Analysis and Design of Algorithms
Bulbul Agrawal
 
PPTX
Algorithm analysis and design
Megha V
 
PPT
Lec1.ppt
ssuser8bddb2
 
PDF
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
TechVision8
 
PDF
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
PDF
complexity analysis.pdf
pasinduneshan
 
PPT
Algorithm
Syam Kumar
 
PPT
Algorithm
Anirban Sarkar
 
PPT
Introduction to design and analysis of algorithm
DevaKumari Vijay
 
PPTX
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
ryadavrohit26
 
PDF
Design Analysis and Algorithm Module1.pdf
Shana799280
 
PPTX
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
shivapatil54
 
CCS 3102 Lecture 3_ Complexity theory.pdf
JosephKariuki46
 
AoA Lec Design of algorithm spresentation
HamzaSadaat
 
Unit ii algorithm
Tribhuvan University
 
Algorithm in Computer, Sorting and Notations
Abid Kohistani
 
algorithmanalysisinfundamentalsofdatastructure-190810085243.pptx
ShirishaBuduputi
 
Chapter1.1 Introduction.ppt
Tekle12
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Tekle12
 
Analysis of Algorithms
Amna Saeed
 
Analysis and Design of Algorithms
Bulbul Agrawal
 
Algorithm analysis and design
Megha V
 
Lec1.ppt
ssuser8bddb2
 
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
TechVision8
 
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
complexity analysis.pdf
pasinduneshan
 
Algorithm
Syam Kumar
 
Algorithm
Anirban Sarkar
 
Introduction to design and analysis of algorithm
DevaKumari Vijay
 
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
ryadavrohit26
 
Design Analysis and Algorithm Module1.pdf
Shana799280
 
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
shivapatil54
 
Ad

Recently uploaded (20)

PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PDF
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PDF
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Alan Turing - life and importance for all of us now
Pedro Concejero
 
PPT
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PPTX
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
PDF
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PDF
13th International Conference on Artificial Intelligence, Soft Computing (AIS...
ijait
 
PDF
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Alan Turing - life and importance for all of us now
Pedro Concejero
 
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
13th International Conference on Artificial Intelligence, Soft Computing (AIS...
ijait
 
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 

Algorithms : Introduction and Analysis

  • 1. Analysis and Design of Algorithms
  • 2. Part 1 Basics of Algorithm 1. Introduction 2. Characteristics 3. Use of Algorithms Analysis and Design of Algorithms 2
  • 3. 1. Introduction I. The word Algorithm come from the name of 9th century Persian mathematician Al-Khwārizmī, Whose work built upon the work of 7th century Indian mathematician Brahmagupta. II. Ada Lovelace invented 1st Algorithm ! III. An Algorithm is any well-defined computational procedure that takes some value or set of values, as input and produces some value or set of values as output. IV. The Internet enables people all around the world to quickly access and retrieve large amount of information. In order to do so, clever algorithms are employed to manage and manipulate this large volume of data. Example of that is, finding good routes on which the data will travel. Analysis and Design of Algorithms 3
  • 4. o If all Algorithms are performing same procedure, all of them are equal and if not then what differentiates them? 1. Correctness of Algorithm I. Produce correct answer always. II. If it is taking lot of time and resources, We build our algorithms as to give the best possible answer. 2. Efficiency of Algorithm I. Time it takes II. Complexity III. Space requirement Analysis and Design of Algorithms 4
  • 5. 2. Characteristics • Modularity • Correctness • Maintainability • Functionality • Robustness • User-friendliness • Simplicity • Programmer time • Extensibility • Reliability Analysis and Design of Algorithms 5
  • 6. 3. Use of Algorithms I. Algorithms help us to understand scalability. II. Public-key cryptography and digital signatures are among the core technologies used and are based on numerical algorithms. III. Algorithmic mathematics provides a language for talking about program behaviour. IV. Speed is fun! V. Local-area and wide-area networking. Analysis and Design of Algorithms 6
  • 7. Part 2 Analysis of Algorithms 1. Overview 2. Time Base Analysis 3. Space Base Analysis 4. Three Cases Analysis and Design of Algorithms 7
  • 8. Figure : Types of analysis Analysis and Design of Algorithms 8 Analysis Time Complexity Space Complexity
  • 9. 1. Time Complexity I. In computer science, the time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the string representing the input. II. The time complexity of an algorithm is commonly expressed using big O notation, which excludes coefficients and lower order terms. Analysis and Design of Algorithms 9
  • 10. 2. Space Complexity I. Space complexity is a measure of the amount of working storage an algorithm needs. That means how much memory, in the worst case, is needed at any point in the algorithm. II. As with time complexity, we're mostly concerned with how the space needs grow, in big-Oh terms, as the size N of the input problem grows. Analysis and Design of Algorithms 10
  • 11. To find Time Complexity of a program Analysis and Design of Algorithms 11 Cost sum = 0; c1 for(i=0; i<N; i++) c2 for(j=0; j<N; j++) c2 sum += arr[i][j]; c3 ------------ c1 + c2 x (N+1) + c2 x N x (N+1) + c3 x N2
  • 12. Three Cases 1. Best Case 2. Average Case 3. Worst Case Analysis and Design of Algorithms 12
  • 13. 1. Best case I. Cheat with a slow algorithm that works fast on some input II. Provides a lower bound on running time III. Input is the one for which the algorithm runs the fastest Analysis and Design of Algorithms 13 Lower Bound RunningTime Upper Bound 
  • 14. 2. Average case I. T(n) = expected time of algorithm over all inputs of size n. II. Need assumption of statistical distribution of inputs. III. Provides a prediction about the running time. IV. Assumes that the input is random. Analysis and Design of Algorithms 14
  • 15. 3. Worst case I. T(n) = maximum time of algorithm on any input of size n. II. Provides an upper bound on running time. III. An absolute guarantee that the algorithm would not run longer, no matter what the inputs are. Analysis and Design of Algorithms 15
  • 16. Analysis of INSERTION sort 16 1]1[8 )1(17 )1(][]1[6 ][05 114 10]11[sequence sortedtheinto][Insert3 1][2 ][21 timescostSORT(A)-INSERTION 8 27 26 25 4 2 1                nckeyiA tcii tciAiA tckeyiAandi ncji njA jA ncjAkey ncAlengthj n j j n j j n j j do while do tofor Analysis and Design of Algorithms
  • 17. Analysis of INSERTION sort I. Total Running Time II. Best Case: The array is already sorted (tj =1 for j=2,3, ...,n) 17 )1()1()1()( 2 6 2 5421    n j j n j j tctcncnccnT ).1()1( 8 2 7    nctc n j j )1()1()1()1()( 85421  ncncncncncnT ).()( 854285421 ccccnccccc  Analysis and Design of Algorithms
  • 18. Analysis of INSERTION sort • Worst Case: The array is reverse sorted (tj =j for j=2,3, ...,n) 18 )12/)1(()1()( 521  nncncncnT )1()2/)1(()2/)1(( 876  ncnncnnc ncccccccnccc )2/2/2/()2/2/2/( 8765421 2 765  2 )1( 1    nn j n j cbnannT  2 )( Analysis and Design of Algorithms
  • 19. Part 3 Asymptotic Notation 1. Big-O Notation - ⃝ 2. Theta Notation - Ө 3. Omega Notation - Ω 4. Example Analysis and Design of Algorithms 19
  • 20. Analysis and Design of Algorithms 20 1. Big-O Notation For a given function g(n), we denote by O(g(n)) the set of functions. The above statement implies that if, f(n)=O(g(n)) then F(n) is always We use the O-notation to give an asymptotic upper bound of a function, to within a constant factor. )(ncg         0 0 allfor)()(0 s.t.andconstantspositiveexistthere:)( ))(( nnncgnf ncnf ngO
  • 21. Analysis and Design of Algorithms 21
  • 22. 2. Ω-Omega Notation I. For a given function , ,we denote by the set of functions. II. The above statement implies that, if f(n)=O(g(n)) then F(n) is always III. We use Ω-notation to give an asymptotic lower bound on a function, to within a constant factor. Analysis and Design of Algorithms 22 )(ng ))(( ng )(ncg         0 0 allfor)()(0 s.t.andconstantspositiveexistthere:)( ))(( nnnfncg ncnf ng
  • 23. Analysis and Design of Algorithms 23
  • 24. 3. Ө-Theta Notation • For a given function , we denote by the set of functions • A function belongs to the set if there exist positive constants c1 and c2 such that it can be “sand- wiched” between and • The above statement implies that, if f(n)=O(g(n)) then F(n) is always Analysis and Design of Algorithms 24 )(ng ))(( ng         021 021 allfor)()()(c0 s.t.and,,constantspositiveexistthere:)( ))(( nnngcnfng nccnf ng )(nf ))(( ng )(1 ngc )(2 ngc )()()( 21 ngcnfngc 
  • 25. Analysis and Design of Algorithms 25
  • 26. 26 Examples (Big-O) •30n+8=O(n). •30n+8  cn, n>n0 . •Let c=31, n0=8. Assume n>n0=8. Then cn = 31n = 30n + n > 30n+8, so 30n+8 < cn. Analysis and Design of Algorithms
  • 27. 27 • Note 30n+8 isn’t less than n anywhere (n>0). • But it is less than 31n everywhere to the right of n=8. n>n0=8  Big-O example, graphically Increasing n  Valueoffunction n 30n+8 cn = 31n 30n+8 O(n) Analysis and Design of Algorithms
  • 28. 28 • Subset relations between order-of-growth sets. Relations Between Different Sets RR ( f )O( f ) ( f ) • f Analysis and Design of Algorithms
  • 29. Thank you. Analysis and Design of Algorithms 29