ALGORITHM ANALYSIS
(
1
OUTLINE
 Algorithm Analysis
 Why do we Need Algorithm Analysis?
 What Does A Better Algorithm Mean?
 Asymptotic Analysis
 Big ‘O’ Notation
2
2
INTRODUCTION
 Algorithm analysis is the study to provide theoretical
estimations for the required resources of an algorithm
to solve a specific computational problem i.e.
calculating efficiency.
 Generally the efficiency of an algorithm is related to
the input length that is the number of steps also
known as time complexity or volume of memory
known as space complexity.
3
WHY DO WE NEED ALGORITHM ANALYSIS
 Knowing the efficiency of an algorithm is
vital on a mission critical task.
 Generally there are multiple approaches or
multiple methods to solve one problem
statement so algorithm. Analysis is performed
to figure out which is a better or optimum
approach out of the different options.
WHAT DOES A BETTER ALGORITHM MEAN?
Faster ? (Less execution time) – Time Complexity
Less Memory ? – Space Complexity
Easy to read ?
Less Line of Code?
Less HW/SW needs?
NOTE: algorithm analysis does not give you accurate or
exact values however it gives us estimate which can be
used to study the behavior of the algorithm
ASYMPTOTIC ANALYSIS
Definition: Asymptotic analysis of an algorithm is a method of defining the
mathematical boundaries of its runtime performance.
Simple words: it is used to mathematically calculate the running time of any
operation inside an algorithm
 Asymptotic algorithm analysis used to estimate the time complexity function
for arbitrarily large input.
 Using the asymptotic analysis we can easily estimate about the average case
best case and worst case scenarios of an algorithm.
 Time complexity is a computational way to show how the runtime of a
program increases as the size of the input increases.
Problem Statement:
Write an algorithm or program to find the sum of N numbers(0-N)
Algorithm 1
function sumOfNumbers(N)
{
sum = 0
for(i = 0 to N)
{
sum = sum + i
}
print(sum)
{
8
Problem Statement:
Write an algorithm or program to find the sum of N numbers(0-N)
Algorithm 2
function
sumOfNumbers(N)
{
sum = (N*(N+1))/2
print(sum)
{
Problem Statement:
Write an algorithm or program to find the sum of N numbers(0-N)
BIG ‘O’ NOTATION
 Big O notation is the formal or mathematical way to
express the upper bound or the worst case scenario of an
algorithm’s running time.
 It measures the worst case time complexity or the largest
amount of time an algorithm can possibly take to
complete.
 Following is the list of some common asymptotic
notations –
10
BIG ‘O’ NOTATION
1
1
CONCLUSION
Understanding Algorithm Analysis and
Asymptotic Algorithm Analysis.
Understanding of Big O Notation, its Importance
and significance.
1
2
13
14

Algo analysis for computational programmingpptx

  • 1.
  • 2.
    OUTLINE  Algorithm Analysis Why do we Need Algorithm Analysis?  What Does A Better Algorithm Mean?  Asymptotic Analysis  Big ‘O’ Notation 2 2
  • 3.
    INTRODUCTION  Algorithm analysisis the study to provide theoretical estimations for the required resources of an algorithm to solve a specific computational problem i.e. calculating efficiency.  Generally the efficiency of an algorithm is related to the input length that is the number of steps also known as time complexity or volume of memory known as space complexity. 3
  • 4.
    WHY DO WENEED ALGORITHM ANALYSIS  Knowing the efficiency of an algorithm is vital on a mission critical task.  Generally there are multiple approaches or multiple methods to solve one problem statement so algorithm. Analysis is performed to figure out which is a better or optimum approach out of the different options.
  • 5.
    WHAT DOES ABETTER ALGORITHM MEAN? Faster ? (Less execution time) – Time Complexity Less Memory ? – Space Complexity Easy to read ? Less Line of Code? Less HW/SW needs? NOTE: algorithm analysis does not give you accurate or exact values however it gives us estimate which can be used to study the behavior of the algorithm
  • 6.
    ASYMPTOTIC ANALYSIS Definition: Asymptoticanalysis of an algorithm is a method of defining the mathematical boundaries of its runtime performance. Simple words: it is used to mathematically calculate the running time of any operation inside an algorithm  Asymptotic algorithm analysis used to estimate the time complexity function for arbitrarily large input.  Using the asymptotic analysis we can easily estimate about the average case best case and worst case scenarios of an algorithm.  Time complexity is a computational way to show how the runtime of a program increases as the size of the input increases.
  • 7.
    Problem Statement: Write analgorithm or program to find the sum of N numbers(0-N) Algorithm 1 function sumOfNumbers(N) { sum = 0 for(i = 0 to N) { sum = sum + i } print(sum) {
  • 8.
    8 Problem Statement: Write analgorithm or program to find the sum of N numbers(0-N)
  • 9.
    Algorithm 2 function sumOfNumbers(N) { sum =(N*(N+1))/2 print(sum) { Problem Statement: Write an algorithm or program to find the sum of N numbers(0-N)
  • 10.
    BIG ‘O’ NOTATION Big O notation is the formal or mathematical way to express the upper bound or the worst case scenario of an algorithm’s running time.  It measures the worst case time complexity or the largest amount of time an algorithm can possibly take to complete.  Following is the list of some common asymptotic notations – 10
  • 11.
  • 12.
    CONCLUSION Understanding Algorithm Analysisand Asymptotic Algorithm Analysis. Understanding of Big O Notation, its Importance and significance. 1 2
  • 13.
  • 14.