SlideShare a Scribd company logo
1 of 26
Download to read offline
Analysis and Algorithms
Introduction
What we should Analyze?
• Correctness
• Does the input/output relationship achieved by the algorithm
requirement?
• Time Complexity
• The amount of computer time it needs to run to completion.
• Space complexity
• The amount of memory it needs to run to completion.
• Optimality
• Is it impossible to do better?
Introduction
Which algorithm is better?
• All feasible algorithms are correct, but which is the best?
• Measure the amount of time used.
• Measure the amount of memory used.
Introduction
Sum of integers?
for i=1 to n
sum=sum + i
int sum (int n)
{
If n==1 then
return 1
else
return (n+sum(n-1))
}
Time Complexity
• It is the amount of computer time required to execute the algorithm.
• T= compilation time + Execution time.
• The execution time depends upon many factors which are not known
therefore we try to estimate it.
• To estimate execution time (te)we count only the number of
steps.
• Time complexity is expressed as a function of input size.
Random Access Machine (RAM) Model
• RAM model is used to analyze the algorithms
• It has one processor.
• Executes one instruction at a time.
• Each simple operation (+, -, =, if, call) takes 1 step.
• Loops and subroutine calls are not simple operations. They depend
upon the size of the data and the contents of a subroutine.
Step Counts
• Comments and declarative statements such as int, struct, #include,
class, etc., counted as zero steps.
• An assignment statement which does not involve any calls to other
programs is counted as one step.
Examples
• Find the sum of integers from 1 to n.
• Sort the elements of an array.
• Find the min from the elements stored in an array.
• Find whether a given number is prime or not.
Examples
• Sum of integers
Algorithm-1
int sum (int n)
{
for i=1 to n
sum= sum +i
} return sum;
Algorithm-2
int sum (int n)
{
If (n==1)
return 1
else
return (n + sum(n-1))
}
Analysis Types
• Worst Case
• T(n)= maximum number of steps taken on any input of size n.
•Best Case
• T(n)= minimum number of steps taken on any input of size n.
• Average Case
• T(n)= average number of steps taken on any input of size n.
• Best case is defined as which input of size n is cheapest among all
inputs of size n.
Analysis Types
Examples
• Sorting elements in an array
Insertion sort (A)
{
for j=2 to n
{
Key= A[j]
i=j-1
While (i>0 and A[i]>key)
{
A[i+1]=A[i]
i=i-1
}
A[i+1]=key
}
Exact Analysis is hard
• Best, worst, and average cases are difficult to deal with precisely
because the details are very complicated.
• The exact number of steps will depend on exactly what machine or
language is being used.
• To avoid that problem, the Asymptotic complexity is generally used.
• For large enough inputs, the running time is mainly affected by the
higher order term.
• Therefore we are interested in the rate of growth, or order of growth,
of the running time.
Asymptotic Complexity
• Asymptotic complexity provides meaningful statements about the
time and space complexities of a program.
• Focus on what’s important by abstracting away low order terms and
constant factors.
• Why important:
• Shows simple characterization of algorithm’s efficiency.
• Comparison of the performance.
Asymptotic Notations
• Big oh notation (O)
• Big omega notation (Ω)
• Theta notation (θ)
Big Oh (O) Notation
Asymptotic upper bound
Big Oh (O) Notation
Figure 2: Graphic representation of Big Oh notation
Big –Omega (Ω) notation
Asymptotic lower bound
Big –Omega (Ω) notation
Figure 2: Graphic representation of (Ω)notation
Theta (θ) Notation
Asymptotically tight bound
Theta (θ) Notation
Figure 1: Graphic representation of θ notation
Set representation of asymptotic notations
Little oh (o)- notation
Little omega (ω) - notation
Recurrences
• A recurrence is an equation or inequality that describes a function
in terms of its value on smaller inputs.
• There three methods of solving recurrences:
• Substitution Method
• Recursion-Tree Method
• Master Method
Thank You

More Related Content

What's hot

Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basicsayeshasafdar8
 
Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.mohanrathod18
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solvingPrabhakaran V M
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Muhammad Hammad Waseem
 
Daa presentation 97
Daa presentation 97Daa presentation 97
Daa presentation 97Garima Verma
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Dr. Pankaj Agarwal
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesFellowBuddy.com
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4Vishal Patil
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Algorithm and Data Structures - Basic of IT Problem Solving
Algorithm and Data Structures - Basic of IT Problem SolvingAlgorithm and Data Structures - Basic of IT Problem Solving
Algorithm and Data Structures - Basic of IT Problem Solvingcoolpie
 
Algorithm analysis and efficiency
Algorithm analysis and efficiencyAlgorithm analysis and efficiency
Algorithm analysis and efficiencyppts123456
 

What's hot (20)

Algorithms.
Algorithms. Algorithms.
Algorithms.
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Types of algorithms
Types of algorithmsTypes of algorithms
Types of algorithms
 
Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Amortized analysis
Amortized analysisAmortized analysis
Amortized analysis
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Daa presentation 97
Daa presentation 97Daa presentation 97
Daa presentation 97
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
#1 designandanalysis of algo
#1 designandanalysis of algo#1 designandanalysis of algo
#1 designandanalysis of algo
 
COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Algorithm and Data Structures - Basic of IT Problem Solving
Algorithm and Data Structures - Basic of IT Problem SolvingAlgorithm and Data Structures - Basic of IT Problem Solving
Algorithm and Data Structures - Basic of IT Problem Solving
 
Algorithm analysis and efficiency
Algorithm analysis and efficiencyAlgorithm analysis and efficiency
Algorithm analysis and efficiency
 

Similar to Analysis and Algorithms: basic Introduction

FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...AntareepMajumder
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptxRahikAhmed1
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptxjinkhatima
 
Analysis of algorithn class 2
Analysis of algorithn class 2Analysis of algorithn class 2
Analysis of algorithn class 2Kumar
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and NotationsAbid Kohistani
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptxrajesshs31r
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxrajesshs31r
 
Slides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdfSlides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdfVijayraj799513
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexityAnaya Zafar
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithmDevaKumari Vijay
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notationsjayavignesh86
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)jehan1987
 

Similar to Analysis and Algorithms: basic Introduction (20)

FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
Analysis of algorithn class 2
Analysis of algorithn class 2Analysis of algorithn class 2
Analysis of algorithn class 2
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 
Slides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdfSlides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdf
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notations
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 

Recently uploaded

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 

Recently uploaded (20)

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 

Analysis and Algorithms: basic Introduction

  • 2. Introduction What we should Analyze? • Correctness • Does the input/output relationship achieved by the algorithm requirement? • Time Complexity • The amount of computer time it needs to run to completion. • Space complexity • The amount of memory it needs to run to completion. • Optimality • Is it impossible to do better?
  • 3. Introduction Which algorithm is better? • All feasible algorithms are correct, but which is the best? • Measure the amount of time used. • Measure the amount of memory used.
  • 4. Introduction Sum of integers? for i=1 to n sum=sum + i int sum (int n) { If n==1 then return 1 else return (n+sum(n-1)) }
  • 5. Time Complexity • It is the amount of computer time required to execute the algorithm. • T= compilation time + Execution time. • The execution time depends upon many factors which are not known therefore we try to estimate it. • To estimate execution time (te)we count only the number of steps. • Time complexity is expressed as a function of input size.
  • 6. Random Access Machine (RAM) Model • RAM model is used to analyze the algorithms • It has one processor. • Executes one instruction at a time. • Each simple operation (+, -, =, if, call) takes 1 step. • Loops and subroutine calls are not simple operations. They depend upon the size of the data and the contents of a subroutine.
  • 7. Step Counts • Comments and declarative statements such as int, struct, #include, class, etc., counted as zero steps. • An assignment statement which does not involve any calls to other programs is counted as one step.
  • 8. Examples • Find the sum of integers from 1 to n. • Sort the elements of an array. • Find the min from the elements stored in an array. • Find whether a given number is prime or not.
  • 9. Examples • Sum of integers Algorithm-1 int sum (int n) { for i=1 to n sum= sum +i } return sum; Algorithm-2 int sum (int n) { If (n==1) return 1 else return (n + sum(n-1)) }
  • 10. Analysis Types • Worst Case • T(n)= maximum number of steps taken on any input of size n. •Best Case • T(n)= minimum number of steps taken on any input of size n. • Average Case • T(n)= average number of steps taken on any input of size n. • Best case is defined as which input of size n is cheapest among all inputs of size n.
  • 12. Examples • Sorting elements in an array Insertion sort (A) { for j=2 to n { Key= A[j] i=j-1 While (i>0 and A[i]>key) { A[i+1]=A[i] i=i-1 } A[i+1]=key }
  • 13. Exact Analysis is hard • Best, worst, and average cases are difficult to deal with precisely because the details are very complicated. • The exact number of steps will depend on exactly what machine or language is being used. • To avoid that problem, the Asymptotic complexity is generally used. • For large enough inputs, the running time is mainly affected by the higher order term. • Therefore we are interested in the rate of growth, or order of growth, of the running time.
  • 14. Asymptotic Complexity • Asymptotic complexity provides meaningful statements about the time and space complexities of a program. • Focus on what’s important by abstracting away low order terms and constant factors. • Why important: • Shows simple characterization of algorithm’s efficiency. • Comparison of the performance.
  • 15. Asymptotic Notations • Big oh notation (O) • Big omega notation (Ω) • Theta notation (θ)
  • 16. Big Oh (O) Notation Asymptotic upper bound
  • 17. Big Oh (O) Notation Figure 2: Graphic representation of Big Oh notation
  • 18. Big –Omega (Ω) notation Asymptotic lower bound
  • 19. Big –Omega (Ω) notation Figure 2: Graphic representation of (Ω)notation
  • 21. Theta (θ) Notation Figure 1: Graphic representation of θ notation
  • 22. Set representation of asymptotic notations
  • 23. Little oh (o)- notation
  • 24. Little omega (ω) - notation
  • 25. Recurrences • A recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs. • There three methods of solving recurrences: • Substitution Method • Recursion-Tree Method • Master Method