SlideShare a Scribd company logo
Asymptotic Analysis
Rachana Mehta
Algorithmic Analysis
Why the algorithmic analysis is necessary ?
Algorithmic Analysis
Why the algorithmic analysis is necessary ?
Efficient :
Less Running Time
Less Memory Used
Efficiency of a Algorithm/Function based on the amount of input
Algorithmic Analysis
Why the algorithmic analysis is necessary ?
Efficient :
Less Running Time : Time Complexity
Less Memory Used : Space Complexity
Efficiency of a Algorithm/Function based on the amount of input
How can we measure the running time of a
algorithm ?
Execution ?
Is it a good choice ?
Measuring the Running Time with a Pseudo-
Code
Generalize language/flow/stepwise instructions for implementing a
algorithm/function
Primitive Operation : Low level Operations :
Data Assignment
Control Statements (break,continue, function call,return)
Arithmetic or Logical Operation
Measuring the Running Time with a Pseudo-
Code
Generalize language/flow/stepwise instructions for implementing a
algorithm/function
Programming Constructs:
for loop, while loop, do-while loop
if-else statement
Asymptotic Notation
Asymptotic notations are the mathematical notations used to describe the
running time of an algorithm
Three Main Asymptotic Notation :
1. Big-O Notation
2. Omega Notation
3. Theta Notation
Asymptotic
Notation
1. Big-O Notation : Upper
Bound : Worst Case Analysis
A Function f(n) belongs to the
set O(g(n)), if there exist a
positive constant c such that
f(n) lies between 0 and
c*g(n), for sufficiently large n.
O(g(n)) = { f(n): there exist
positive constants c and n0 such
that 0 ≤ f(n) ≤ cg(n) for all n ≥
n0 }
Asymptotic
Notation
2. Omega Notation : Lower
Bound : Best Case Analysis
A Function f(n) belongs to the
set Ω(g(n)), if there exist a
positive constant c such that
f(n) lies above c*g(n), for
sufficiently large n.
Ω(g(n)) = { f(n): there exist
positive constants c and n0 such
that 0 ≤ cg(n) ≤ f(n) for all n ≥
n0 }
Asymptotic
Notation
3. Theta Notation : Average
Case Analysis
A Function f(n) belongs to the
set ϴ(g(n)), if there exist a
positive constant c1 and c2
such that f(n) lies between c1
*g(n) and c2 *g(n), for
sufficiently large n.
Θ (g(n)) = {f(n): there exist
positive constants c1, c2 and n0
such that 0 ≤ c1 * g(n) ≤ f(n) ≤
c2 * g(n) for all n ≥ n0}
Rules for Order Arithmetic:
Multiplicative Constants O(k * f(n)) = O(f(n))
Addition Rule O(f(n) + g(n)) = max(f(n), g(n))
Multiplication Rule O(f(n) * g(n)) = O(f(n)) * O(g(n))
Examples: O(1000n) = O(n)
O(n2
+ 3n + 2) = O(n2
)
O(3n3
+ 6n2
- 4n + 2) = O(3n3
) = O(n3
)
If f(x) = n2
* log n = O(n2
logn)
Asymptotic Growth Table
Examples
for (i = 0; i < n; i++)
cin>>A[i];
Examples
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
cin >> A[i][j];
Examples
for (i = 0; i < n; i++)
for (j = 0; j < i; j++)
cin >> A[i][j];
Examples
for (i = 0; i < n; i++)
cin>>B[i];
for (i = 0; i < n; i++)
for (j = 0; j < i; j++)
cin >> A[i][j];
Examples
for (i = 0; i < n; i++)
for (k = 0;k < n; k++)
cin>>B[k];
for (j = 0; j < 2*n; j++)
cin >> “Hello”;
cin >> A[j];
Examples
for (i = 0; i < n; i++)
for (k = 0;k < n; k++)
cin>>B[k];
for (m = 0; m < n; m++)
for (j = 0; j < 2*n; j++)
cin >> “Hello”;
cin >> A[j];
Examples
int i = 0; int A[100]; int n =100;
Take a number for “rollno” from user
while(( A[i] != rollno) && (i<n))
i++;
if (i > n)
cout << "not found";
else cout << "found";
Examples
int i = n;
while( i>=1)
x = x+1 ;
i = i/2;
Insertion Sort - Sample
Insertion Sort - Algorithm
Insertion Sort
Insertion Sort
Insertion Sort

More Related Content

PPTX
Data structures notes for college students btech.pptx
PPTX
Introduction to Algorithms and Asymptotic Notation
PPTX
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
PPTX
Time complexity.pptxghhhhhhhhhhhhhhhjjjjjjjjjjjjjjjjjjjjjjjjjj
PPTX
Daa unit 6_efficiency of algorithms
PPTX
DS Unit-1.pptx very easy to understand..
PPTX
Data Structure Algorithm -Algorithm Complexity
Data structures notes for college students btech.pptx
Introduction to Algorithms and Asymptotic Notation
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Time complexity.pptxghhhhhhhhhhhhhhhjjjjjjjjjjjjjjjjjjjjjjjjjj
Daa unit 6_efficiency of algorithms
DS Unit-1.pptx very easy to understand..
Data Structure Algorithm -Algorithm Complexity

Similar to Asymptotic Analysis in Data Structures and Analysis (20)

PDF
Data Structures and Algorithms - Lec 02.pdf
PDF
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
PPT
Basics of data structure types of data structures
PPT
lecture 1
PPTX
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
PPT
CS8451 - Design and Analysis of Algorithms
PPTX
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
PPTX
Lecture 2 data structures and algorithms
PPT
Data_Structure_and_Algorithms_Lecture_1.ppt
PDF
Complexity
PPTX
1.algorithms
PPT
How to calculate complexity in Data Structure
PPT
Time complexity.ppt
PPT
Time complexity.pptr56435 erfgegr t 45t 35
PPTX
DESIGN AND ALGORITHM.pptx BCA BANGALORECITY UNIVERSITY
PDF
Data Structure & Algorithms - Mathematical
PPT
how to calclute time complexity of algortihm
PDF
CS-102 DS-class_01_02 Lectures Data .pdf
PPT
Data Structures- Part2 analysis tools
PDF
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Data Structures and Algorithms - Lec 02.pdf
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
Basics of data structure types of data structures
lecture 1
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
CS8451 - Design and Analysis of Algorithms
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Lecture 2 data structures and algorithms
Data_Structure_and_Algorithms_Lecture_1.ppt
Complexity
1.algorithms
How to calculate complexity in Data Structure
Time complexity.ppt
Time complexity.pptr56435 erfgegr t 45t 35
DESIGN AND ALGORITHM.pptx BCA BANGALORECITY UNIVERSITY
Data Structure & Algorithms - Mathematical
how to calclute time complexity of algortihm
CS-102 DS-class_01_02 Lectures Data .pdf
Data Structures- Part2 analysis tools
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Ad

Recently uploaded (20)

PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPT
Reliability_Chapter_ presentation 1221.5784
PDF
Business Analytics and business intelligence.pdf
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
Lecture1 pattern recognition............
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PDF
Mega Projects Data Mega Projects Data
PDF
Foundation of Data Science unit number two notes
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
Miokarditis (Inflamasi pada Otot Jantung)
Introduction to Knowledge Engineering Part 1
Business Acumen Training GuidePresentation.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Reliability_Chapter_ presentation 1221.5784
Business Analytics and business intelligence.pdf
climate analysis of Dhaka ,Banglades.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
1_Introduction to advance data techniques.pptx
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Lecture1 pattern recognition............
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Mega Projects Data Mega Projects Data
Foundation of Data Science unit number two notes
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
oil_refinery_comprehensive_20250804084928 (1).pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
Ad

Asymptotic Analysis in Data Structures and Analysis

  • 2. Algorithmic Analysis Why the algorithmic analysis is necessary ?
  • 3. Algorithmic Analysis Why the algorithmic analysis is necessary ? Efficient : Less Running Time Less Memory Used Efficiency of a Algorithm/Function based on the amount of input
  • 4. Algorithmic Analysis Why the algorithmic analysis is necessary ? Efficient : Less Running Time : Time Complexity Less Memory Used : Space Complexity Efficiency of a Algorithm/Function based on the amount of input
  • 5. How can we measure the running time of a algorithm ? Execution ? Is it a good choice ?
  • 6. Measuring the Running Time with a Pseudo- Code Generalize language/flow/stepwise instructions for implementing a algorithm/function Primitive Operation : Low level Operations : Data Assignment Control Statements (break,continue, function call,return) Arithmetic or Logical Operation
  • 7. Measuring the Running Time with a Pseudo- Code Generalize language/flow/stepwise instructions for implementing a algorithm/function Programming Constructs: for loop, while loop, do-while loop if-else statement
  • 8. Asymptotic Notation Asymptotic notations are the mathematical notations used to describe the running time of an algorithm Three Main Asymptotic Notation : 1. Big-O Notation 2. Omega Notation 3. Theta Notation
  • 9. Asymptotic Notation 1. Big-O Notation : Upper Bound : Worst Case Analysis A Function f(n) belongs to the set O(g(n)), if there exist a positive constant c such that f(n) lies between 0 and c*g(n), for sufficiently large n. O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0 }
  • 10. Asymptotic Notation 2. Omega Notation : Lower Bound : Best Case Analysis A Function f(n) belongs to the set Ω(g(n)), if there exist a positive constant c such that f(n) lies above c*g(n), for sufficiently large n. Ω(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ cg(n) ≤ f(n) for all n ≥ n0 }
  • 11. Asymptotic Notation 3. Theta Notation : Average Case Analysis A Function f(n) belongs to the set ϴ(g(n)), if there exist a positive constant c1 and c2 such that f(n) lies between c1 *g(n) and c2 *g(n), for sufficiently large n. Θ (g(n)) = {f(n): there exist positive constants c1, c2 and n0 such that 0 ≤ c1 * g(n) ≤ f(n) ≤ c2 * g(n) for all n ≥ n0}
  • 12. Rules for Order Arithmetic: Multiplicative Constants O(k * f(n)) = O(f(n)) Addition Rule O(f(n) + g(n)) = max(f(n), g(n)) Multiplication Rule O(f(n) * g(n)) = O(f(n)) * O(g(n)) Examples: O(1000n) = O(n) O(n2 + 3n + 2) = O(n2 ) O(3n3 + 6n2 - 4n + 2) = O(3n3 ) = O(n3 ) If f(x) = n2 * log n = O(n2 logn)
  • 14. Examples for (i = 0; i < n; i++) cin>>A[i];
  • 15. Examples for (i = 0; i < n; i++) for (j = 0; j < n; j++) cin >> A[i][j];
  • 16. Examples for (i = 0; i < n; i++) for (j = 0; j < i; j++) cin >> A[i][j];
  • 17. Examples for (i = 0; i < n; i++) cin>>B[i]; for (i = 0; i < n; i++) for (j = 0; j < i; j++) cin >> A[i][j];
  • 18. Examples for (i = 0; i < n; i++) for (k = 0;k < n; k++) cin>>B[k]; for (j = 0; j < 2*n; j++) cin >> “Hello”; cin >> A[j];
  • 19. Examples for (i = 0; i < n; i++) for (k = 0;k < n; k++) cin>>B[k]; for (m = 0; m < n; m++) for (j = 0; j < 2*n; j++) cin >> “Hello”; cin >> A[j];
  • 20. Examples int i = 0; int A[100]; int n =100; Take a number for “rollno” from user while(( A[i] != rollno) && (i<n)) i++; if (i > n) cout << "not found"; else cout << "found";
  • 21. Examples int i = n; while( i>=1) x = x+1 ; i = i/2;
  • 23. Insertion Sort - Algorithm