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

Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
Swapnil Agrawal
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
Muhammad Muzammal
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1Kumar
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
smruti sarangi
 
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
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O Analysis
Ömer Faruk Öztürk
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
Bulbul Agrawal
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Pranay Neema
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
Dr Shashikant Athawale
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
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 algortihmSajid Marwat
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
Mohamed Loey
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph Algorithms
Mohamed Loey
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
Dr Geetha Mohan
 

What's hot (20)

Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
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.
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O Analysis
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
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
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph Algorithms
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 

Viewers also liked

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
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
Mohamed Loey
 

Viewers also liked (7)

Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
 
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
 
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
 
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
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSA
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 

Similar to Algorithms Lecture 2: Analysis of Algorithms I

Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
Mallikarjun Biradar
 
Lec7
Lec7Lec7
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
 
Measuring algorithm performance
Measuring algorithm performanceMeasuring algorithm performance
Measuring algorithm performance
HabitamuAsimare
 
18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)
AdityaKhandelwal58
 
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
 
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
TechVision8
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
NishaS88
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisAnindita Kundu
 
Analysis of Algorithum
Analysis of AlgorithumAnalysis of Algorithum
Analysis of Algorithum
Ain-ul-Moiz Khawaja
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
Afaq Mansoor Khan
 
Algorithms : Introduction and Analysis
Algorithms : Introduction and AnalysisAlgorithms : Introduction and Analysis
Algorithms : Introduction and Analysis
Dhrumil Patel
 
Time_Complexity.pptx
Time_Complexity.pptxTime_Complexity.pptx
Time_Complexity.pptx
vivekcommon
 

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

Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Lec7
Lec7Lec7
Lec7
 
Lec7.ppt
Lec7.pptLec7.ppt
Lec7.ppt
 
Lec7.ppt
Lec7.pptLec7.ppt
Lec7.ppt
 
analysis of algorithms
analysis of algorithmsanalysis of algorithms
analysis of algorithms
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Measuring algorithm performance
Measuring algorithm performanceMeasuring algorithm performance
Measuring algorithm performance
 
18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)
 
Analysis.ppt
Analysis.pptAnalysis.ppt
Analysis.ppt
 
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
 
Analysis of algo
Analysis of algoAnalysis of algo
Analysis of algo
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysis
 
Analysis of Algorithum
Analysis of AlgorithumAnalysis of Algorithum
Analysis of Algorithum
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Algorithms : Introduction and Analysis
Algorithms : Introduction and AnalysisAlgorithms : Introduction and Analysis
Algorithms : Introduction and Analysis
 
Time_Complexity.pptx
Time_Complexity.pptxTime_Complexity.pptx
Time_Complexity.pptx
 

More from 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
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching 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
 

More from Mohamed Loey (20)

Lecture 6: Deep Learning Applications
Lecture 6: Deep Learning ApplicationsLecture 6: Deep Learning Applications
Lecture 6: Deep Learning Applications
 
Lecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network ModelsLecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network Models
 
Lecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning FrameworksLecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning Frameworks
 
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
 
Lecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural NetworksLecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural Networks
 
Lecture 2: Artificial Neural Network
Lecture 2: Artificial Neural NetworkLecture 2: Artificial Neural Network
Lecture 2: Artificial Neural Network
 
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
 
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
 
Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2
 
Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching Algorithms
 
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
 
PMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration ManagementPMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration Management
 
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
 
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
 
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
 
Computer Security Lecture 1: Overview
Computer Security Lecture 1: OverviewComputer Security Lecture 1: Overview
Computer Security Lecture 1: Overview
 
PMP Lecture 3: Project Management Processes
PMP Lecture 3: Project Management ProcessesPMP Lecture 3: Project Management Processes
PMP Lecture 3: Project Management Processes
 
PMP Lecture 2: Project Management Framework
PMP Lecture 2: Project Management FrameworkPMP Lecture 2: Project Management Framework
PMP Lecture 2: Project Management Framework
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

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 mohamedloey@gmail.com twitter.com/mloey linkedin.com/in/mloey mloey@fci.bu.edu.eg mloey.github.io
  • 43. Analysis and Design of Algorithms www.YourCompany.com © 2020 Companyname PowerPoint Business Theme. All Rights Reserved. THANKS FOR YOUR TIME