SlideShare a Scribd company logo
Analysis and Design of Algorithms
Analysis of Algorithms I
Analysis and Design of Algorithms
Analysis of Algorithms
Time complexity
Asymptotic Notations
Big O Notation
Growth Orders
Problems
Analysis and Design of Algorithms
Analysis of Algorithms is the determination of the
amount of time, storage and/or other resources necessary
to execute them.
Analyzing algorithms is called Asymptotic Analysis
Asymptotic Analysis evaluate the performance of an
algorithm
Analysis and Design of Algorithms
Time complexity
Analysis and Design of Algorithms
 time complexity of an algorithm quantifies the amount of time taken
by an algorithm
 We can have three cases to analyze an algorithm:
1) Worst Case
2) Average Case
3) Best Case
Analysis and Design of Algorithms
 Assume the below algorithm using Python code:
Analysis and Design of Algorithms
 Worst Case Analysis: In the worst case analysis, we calculate upper
bound on running time of an algorithm.
Analysis and Design of Algorithms
 Worst Case Analysis: the case that causes maximum number of
operations to be executed.
 For Linear Search, the worst case happens when the element to be
searched is not present in the array. (example : search for number
8)
2 3 5 4 1 7 6
Analysis and Design of Algorithms
 Worst Case Analysis: When x is not present, the search() functions
compares it with all the elements of arr one by one.
Analysis and Design of Algorithms
 The worst case time complexity of linear search would be O(n).
Analysis and Design of Algorithms
 Average Case Analysis: we take all possible inputs and calculate
computing time for all of the inputs.
Analysis and Design of Algorithms
 Best Case Analysis: calculate lower bound on running time of an
algorithm.
Analysis and Design of Algorithms
 The best case time complexity of linear search would be O(1).
Analysis and Design of Algorithms
 Best Case Analysis: the case that causes minimum number of
operations to be executed.
 For Linear Search, the best case occurs when x is present at the first
location. (example : search for number 2)
 So time complexity in the best case would be Θ(1)
2 3 5 4 1 7 6
Analysis and Design of Algorithms
 Most of the times, we do worst case analysis to analyze algorithms.
 The average case analysis is not easy to do in most of the practical
cases and it is rarely done.
 The Best case analysis is bogus. Guaranteeing a lower bound on an
algorithm doesn’t provide any information.
Analysis and Design of Algorithms
1) Big O Notation: is an Asymptotic Notation for the worst case.
2) Ω Notation (omega notation): is an Asymptotic Notation for the
best case.
3) Θ Notation (theta notation) : is an Asymptotic Notation for the
worst case and the best case.
Analysis and Design of Algorithms
Big O Notation
Analysis and Design of Algorithms
1) O(1)
 Time complexity of a function (or set of statements) is considered as
O(1) if it doesn’t contain loop, recursion and call to any other non-
constant time function. For example swap() function has O(1) time
complexity.
Analysis and Design of Algorithms
 A loop or recursion that runs a constant number of times is also
considered as O(1). For example the following loop is O(1).
Analysis and Design of Algorithms
2) O(n)
 Time Complexity of a loop is considered as O(n) if the loop
variables is incremented / decremented by a constant amount. For
example the following loop statements have O(n) time complexity.
Analysis and Design of Algorithms
2) O(n)
Analysis and Design of Algorithms
2) O(n)
 Another Example:
Analysis and Design of Algorithms
3) O(nc)
 Time complexity of nested loops is equal to the number of times the
innermost statement is executed. For example the following loop
statements have O(n2) time complexity
Analysis and Design of Algorithms
3) O(n2)
Analysis and Design of Algorithms
 Another Example
Analysis and Design of Algorithms
4) O(Logn)
 Time Complexity of a loop is considered as O(Logn) if the loop
variables is divided / multiplied by a constant amount.
Analysis and Design of Algorithms
4) O(Logn)
 Another Example
Analysis and Design of Algorithms
5) O(LogLogn)
 Time Complexity of a loop is considered as O(LogLogn) if the loop
variables is reduced / increased exponentially by a constant.
Analysis and Design of Algorithms
5) O(LogLogn)
 Another Example
Analysis and Design of Algorithms
 How to combine time complexities of consecutive loops?
 Time complexity of above code is O(n) + O(m) which is O(n+m)
Analysis and Design of Algorithms
n O(1) O(log(n)) O(n) O(nlog(n)) O(N2) O(2n) O(n!)
1 1 0 1 1 1 2 1
8 1 3 8 24 64 256 40xx103
30 1 5 30 150 900 10x109 210x1032
500 1 9 500 4500 25x104 3x10150 1x101134
1000 1 10 1000 10x103 1x106 1x10301 4x102567
16x103 1 14 16x103 224x103 256x106 - -
1x105 1 17 1x105 17x105 10x109 - -
Analysis and Design of Algorithms
Analysis and Design of Algorithms
Length of Input (N) Worst Accepted Algorithm
≤10 O(N!),O(N6)
≤15 O(2N∗N2)
≤20 O(2N∗N)
≤100 O(N4)
≤400 O(N3)
≤2K O(N2∗logN)
≤10K O(N2)
≤1M O(N∗logN)
≤100M O(N),O(logN),O(1)
Analysis and Design of Algorithms
 Find the complexity
of the below
program:
Analysis and Design of Algorithms
 Solution: Time
Complexity O(n).
Even though the
inner loop is
bounded by n, but
due to break
statement it is
executing only once.
Analysis and Design of Algorithms
 Find the complexity of the below program:
Analysis and Design of Algorithms
 Solution:
Time
O(n2logn)
Analysis and Design of Algorithms
 Find the complexity of the below program:
Analysis and Design of Algorithms
 Solution:
Time
O(n log2n)
Analysis and Design of Algorithms
 Find the
complexity
of the
below
program:
Analysis and Design of Algorithms
 Solution:
Time O(n5)
Analysis and Design of Algorithms
facebook.com/mloey
mohamedloey@gmail.com
twitter.com/mloey
linkedin.com/in/mloey
mloey@fci.bu.edu.eg
mloey.github.io
Analysis and Design of Algorithms
www.YourCompany.com
© 2020 Companyname PowerPoint Business Theme. All Rights Reserved.
THANKS FOR
YOUR TIME

More Related Content

What's hot (20)

Time andspacecomplexity
Time andspacecomplexityTime andspacecomplexity
Time andspacecomplexity
LAKSHMITHARUN PONNAM
 
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
Mary Margarat
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Ehtisham Ali
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
Daffodil International University
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
Protap Mondal
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
Sahil Kumar
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
Muhammad Muzammal
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
Zia Ush Shamszaman
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
Sajid Marwat
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
Mary Margarat
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Ehtisham Ali
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
Sahil Kumar
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
Zia Ush Shamszaman
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
Sajid Marwat
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 

Viewers also liked (6)

Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work II
Mohamed Loey
 
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption StandardComputer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Mohamed Loey
 
PMP Lecture 1: Introduction to Project Management
PMP Lecture 1: Introduction to Project ManagementPMP Lecture 1: Introduction to Project Management
PMP Lecture 1: Introduction to Project Management
Mohamed Loey
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSA
Mohamed Loey
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
Mohamed Loey
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work II
Mohamed Loey
 
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption StandardComputer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Mohamed Loey
 
PMP Lecture 1: Introduction to Project Management
PMP Lecture 1: Introduction to Project ManagementPMP Lecture 1: Introduction to Project Management
PMP Lecture 1: Introduction to Project Management
Mohamed Loey
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSA
Mohamed Loey
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
Mohamed Loey
 
Ad

Similar to Algorithms Lecture 2: Analysis of Algorithms I (20)

Time Complexity of Algorithm (Analysis).pdf
Time Complexity of Algorithm (Analysis).pdfTime Complexity of Algorithm (Analysis).pdf
Time Complexity of Algorithm (Analysis).pdf
Christian833679
 
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
BCSE202LkkljkljkbbbnbnghghjghghghghghghghghBCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
shivapatil54
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
Mallikarjun Biradar
 
complexity big oh notation notation.pptx
complexity big oh notation notation.pptxcomplexity big oh notation notation.pptx
complexity big oh notation notation.pptx
narifmsit18seecs
 
Lec7
Lec7Lec7
Lec7
TejaswiEnugurthi
 
Lec7.ppt
Lec7.pptLec7.ppt
Lec7.ppt
Agung Kurniawan
 
Lec7.ppt
Lec7.pptLec7.ppt
Lec7.ppt
NikhilKatariya8
 
analysis of algorithms
analysis of algorithmsanalysis of algorithms
analysis of algorithms
MyMovies15
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
subhashchandra197
 
Measuring algorithm performance
Measuring algorithm performanceMeasuring algorithm performance
Measuring algorithm performance
HabitamuAsimare
 
Data Structure - Lecture 1 - Introduction.pdf
Data Structure  - Lecture 1 - Introduction.pdfData Structure  - Lecture 1 - Introduction.pdf
Data Structure - Lecture 1 - Introduction.pdf
donotreply20
 
18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)
AdityaKhandelwal58
 
Algorithm for the DAA agscsnak javausmagagah
Algorithm for the DAA agscsnak javausmagagahAlgorithm for the DAA agscsnak javausmagagah
Algorithm for the DAA agscsnak javausmagagah
RaviPandey598038
 
Analysis.ppt
Analysis.pptAnalysis.ppt
Analysis.ppt
ShivaniSharma335055
 
complex computer systems and its applications.pptx
complex computer systems and its applications.pptxcomplex computer systems and its applications.pptx
complex computer systems and its applications.pptx
narifmsit18seecs
 
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjcModule-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
shashashashashank
 
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptxData Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
RashidFaridChishti
 
Analysis of algo
Analysis of algoAnalysis of algo
Analysis of algo
Sandeep Bhargava
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
Abid Kohistani
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
Natarajan Angappan
 
Time Complexity of Algorithm (Analysis).pdf
Time Complexity of Algorithm (Analysis).pdfTime Complexity of Algorithm (Analysis).pdf
Time Complexity of Algorithm (Analysis).pdf
Christian833679
 
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
BCSE202LkkljkljkbbbnbnghghjghghghghghghghghBCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
shivapatil54
 
complexity big oh notation notation.pptx
complexity big oh notation notation.pptxcomplexity big oh notation notation.pptx
complexity big oh notation notation.pptx
narifmsit18seecs
 
analysis of algorithms
analysis of algorithmsanalysis of algorithms
analysis of algorithms
MyMovies15
 
Measuring algorithm performance
Measuring algorithm performanceMeasuring algorithm performance
Measuring algorithm performance
HabitamuAsimare
 
Data Structure - Lecture 1 - Introduction.pdf
Data Structure  - Lecture 1 - Introduction.pdfData Structure  - Lecture 1 - Introduction.pdf
Data Structure - Lecture 1 - Introduction.pdf
donotreply20
 
18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)
AdityaKhandelwal58
 
Algorithm for the DAA agscsnak javausmagagah
Algorithm for the DAA agscsnak javausmagagahAlgorithm for the DAA agscsnak javausmagagah
Algorithm for the DAA agscsnak javausmagagah
RaviPandey598038
 
complex computer systems and its applications.pptx
complex computer systems and its applications.pptxcomplex computer systems and its applications.pptx
complex computer systems and its applications.pptx
narifmsit18seecs
 
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjcModule-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
shashashashashank
 
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptxData Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
RashidFaridChishti
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
Abid Kohistani
 
Ad

More from Mohamed Loey (19)

Lecture 6: Deep Learning Applications
Lecture 6: Deep Learning ApplicationsLecture 6: Deep Learning Applications
Lecture 6: Deep Learning Applications
Mohamed Loey
 
Lecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network ModelsLecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
Lecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning FrameworksLecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Lecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural NetworksLecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural Networks
Mohamed Loey
 
Lecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural NetworksLecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural Networks
Mohamed Loey
 
Lecture 2: Artificial Neural Network
Lecture 2: Artificial Neural NetworkLecture 2: Artificial Neural Network
Lecture 2: Artificial Neural Network
Mohamed Loey
 
Lecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer VisionLecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer Vision
Mohamed Loey
 
Design of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer DiseasesDesign of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer Diseases
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1
Mohamed Loey
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Computer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary MaterialComputer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary Material
Mohamed Loey
 
PMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration ManagementPMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration Management
Mohamed Loey
 
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption StandardComputer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Mohamed Loey
 
Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2
Mohamed Loey
 
Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1
Mohamed Loey
 
Computer Security Lecture 1: Overview
Computer Security Lecture 1: OverviewComputer Security Lecture 1: Overview
Computer Security Lecture 1: Overview
Mohamed Loey
 
PMP Lecture 3: Project Management Processes
PMP Lecture 3: Project Management ProcessesPMP Lecture 3: Project Management Processes
PMP Lecture 3: Project Management Processes
Mohamed Loey
 
PMP Lecture 2: Project Management Framework
PMP Lecture 2: Project Management FrameworkPMP Lecture 2: Project Management Framework
PMP Lecture 2: Project Management Framework
Mohamed Loey
 
Lecture 6: Deep Learning Applications
Lecture 6: Deep Learning ApplicationsLecture 6: Deep Learning Applications
Lecture 6: Deep Learning Applications
Mohamed Loey
 
Lecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network ModelsLecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
Lecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning FrameworksLecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Lecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural NetworksLecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural Networks
Mohamed Loey
 
Lecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural NetworksLecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural Networks
Mohamed Loey
 
Lecture 2: Artificial Neural Network
Lecture 2: Artificial Neural NetworkLecture 2: Artificial Neural Network
Lecture 2: Artificial Neural Network
Mohamed Loey
 
Lecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer VisionLecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer Vision
Mohamed Loey
 
Design of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer DiseasesDesign of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer Diseases
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1
Mohamed Loey
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Computer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary MaterialComputer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary Material
Mohamed Loey
 
PMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration ManagementPMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration Management
Mohamed Loey
 
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption StandardComputer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Mohamed Loey
 
Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2
Mohamed Loey
 
Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1
Mohamed Loey
 
Computer Security Lecture 1: Overview
Computer Security Lecture 1: OverviewComputer Security Lecture 1: Overview
Computer Security Lecture 1: Overview
Mohamed Loey
 
PMP Lecture 3: Project Management Processes
PMP Lecture 3: Project Management ProcessesPMP Lecture 3: Project Management Processes
PMP Lecture 3: Project Management Processes
Mohamed Loey
 
PMP Lecture 2: Project Management Framework
PMP Lecture 2: Project Management FrameworkPMP Lecture 2: Project Management Framework
PMP Lecture 2: Project Management Framework
Mohamed Loey
 

Recently uploaded (20)

IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
National Information Standards Organization (NISO)
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 

Algorithms Lecture 2: Analysis of Algorithms I

  • 1. Analysis and Design of Algorithms Analysis of Algorithms I
  • 2. Analysis and Design of Algorithms Analysis of Algorithms Time complexity Asymptotic Notations Big O Notation Growth Orders Problems
  • 3. Analysis and Design of Algorithms Analysis of Algorithms is the determination of the amount of time, storage and/or other resources necessary to execute them. Analyzing algorithms is called Asymptotic Analysis Asymptotic Analysis evaluate the performance of an algorithm
  • 4. Analysis and Design of Algorithms Time complexity
  • 5. Analysis and Design of Algorithms  time complexity of an algorithm quantifies the amount of time taken by an algorithm  We can have three cases to analyze an algorithm: 1) Worst Case 2) Average Case 3) Best Case
  • 6. Analysis and Design of Algorithms  Assume the below algorithm using Python code:
  • 7. Analysis and Design of Algorithms  Worst Case Analysis: In the worst case analysis, we calculate upper bound on running time of an algorithm.
  • 8. Analysis and Design of Algorithms  Worst Case Analysis: the case that causes maximum number of operations to be executed.  For Linear Search, the worst case happens when the element to be searched is not present in the array. (example : search for number 8) 2 3 5 4 1 7 6
  • 9. Analysis and Design of Algorithms  Worst Case Analysis: When x is not present, the search() functions compares it with all the elements of arr one by one.
  • 10. Analysis and Design of Algorithms  The worst case time complexity of linear search would be O(n).
  • 11. Analysis and Design of Algorithms  Average Case Analysis: we take all possible inputs and calculate computing time for all of the inputs.
  • 12. Analysis and Design of Algorithms  Best Case Analysis: calculate lower bound on running time of an algorithm.
  • 13. Analysis and Design of Algorithms  The best case time complexity of linear search would be O(1).
  • 14. Analysis and Design of Algorithms  Best Case Analysis: the case that causes minimum number of operations to be executed.  For Linear Search, the best case occurs when x is present at the first location. (example : search for number 2)  So time complexity in the best case would be Θ(1) 2 3 5 4 1 7 6
  • 15. Analysis and Design of Algorithms  Most of the times, we do worst case analysis to analyze algorithms.  The average case analysis is not easy to do in most of the practical cases and it is rarely done.  The Best case analysis is bogus. Guaranteeing a lower bound on an algorithm doesn’t provide any information.
  • 16. Analysis and Design of Algorithms 1) Big O Notation: is an Asymptotic Notation for the worst case. 2) Ω Notation (omega notation): is an Asymptotic Notation for the best case. 3) Θ Notation (theta notation) : is an Asymptotic Notation for the worst case and the best case.
  • 17. Analysis and Design of Algorithms Big O Notation
  • 18. Analysis and Design of Algorithms 1) O(1)  Time complexity of a function (or set of statements) is considered as O(1) if it doesn’t contain loop, recursion and call to any other non- constant time function. For example swap() function has O(1) time complexity.
  • 19. Analysis and Design of Algorithms  A loop or recursion that runs a constant number of times is also considered as O(1). For example the following loop is O(1).
  • 20. Analysis and Design of Algorithms 2) O(n)  Time Complexity of a loop is considered as O(n) if the loop variables is incremented / decremented by a constant amount. For example the following loop statements have O(n) time complexity.
  • 21. Analysis and Design of Algorithms 2) O(n)
  • 22. Analysis and Design of Algorithms 2) O(n)  Another Example:
  • 23. Analysis and Design of Algorithms 3) O(nc)  Time complexity of nested loops is equal to the number of times the innermost statement is executed. For example the following loop statements have O(n2) time complexity
  • 24. Analysis and Design of Algorithms 3) O(n2)
  • 25. Analysis and Design of Algorithms  Another Example
  • 26. Analysis and Design of Algorithms 4) O(Logn)  Time Complexity of a loop is considered as O(Logn) if the loop variables is divided / multiplied by a constant amount.
  • 27. Analysis and Design of Algorithms 4) O(Logn)  Another Example
  • 28. Analysis and Design of Algorithms 5) O(LogLogn)  Time Complexity of a loop is considered as O(LogLogn) if the loop variables is reduced / increased exponentially by a constant.
  • 29. Analysis and Design of Algorithms 5) O(LogLogn)  Another Example
  • 30. Analysis and Design of Algorithms  How to combine time complexities of consecutive loops?  Time complexity of above code is O(n) + O(m) which is O(n+m)
  • 31. Analysis and Design of Algorithms n O(1) O(log(n)) O(n) O(nlog(n)) O(N2) O(2n) O(n!) 1 1 0 1 1 1 2 1 8 1 3 8 24 64 256 40xx103 30 1 5 30 150 900 10x109 210x1032 500 1 9 500 4500 25x104 3x10150 1x101134 1000 1 10 1000 10x103 1x106 1x10301 4x102567 16x103 1 14 16x103 224x103 256x106 - - 1x105 1 17 1x105 17x105 10x109 - -
  • 32. Analysis and Design of Algorithms
  • 33. Analysis and Design of Algorithms Length of Input (N) Worst Accepted Algorithm ≤10 O(N!),O(N6) ≤15 O(2N∗N2) ≤20 O(2N∗N) ≤100 O(N4) ≤400 O(N3) ≤2K O(N2∗logN) ≤10K O(N2) ≤1M O(N∗logN) ≤100M O(N),O(logN),O(1)
  • 34. Analysis and Design of Algorithms  Find the complexity of the below program:
  • 35. Analysis and Design of Algorithms  Solution: Time Complexity O(n). Even though the inner loop is bounded by n, but due to break statement it is executing only once.
  • 36. Analysis and Design of Algorithms  Find the complexity of the below program:
  • 37. Analysis and Design of Algorithms  Solution: Time O(n2logn)
  • 38. Analysis and Design of Algorithms  Find the complexity of the below program:
  • 39. Analysis and Design of Algorithms  Solution: Time O(n log2n)
  • 40. Analysis and Design of Algorithms  Find the complexity of the below program:
  • 41. Analysis and Design of Algorithms  Solution: Time O(n5)
  • 42. Analysis and Design of Algorithms facebook.com/mloey [email protected] twitter.com/mloey linkedin.com/in/mloey [email protected] mloey.github.io
  • 43. Analysis and Design of Algorithms www.YourCompany.com © 2020 Companyname PowerPoint Business Theme. All Rights Reserved. THANKS FOR YOUR TIME