SlideShare a Scribd company logo
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
1
S. Hassan Adelyar, Ph.D
Instructor of Computer Science Faculty
Kabul University
December 2020
Lesson II: Algorithm-Analysis Part I
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
2
Learning Outcome
 By the end of this presentation, students will
be able to:
 Analyze Algorithm
 Identify the resources for analysis
 Understand experimental approach for
analysis
 Understand the analytical approach for
analysis
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
3
Algorithm Analysis
 After correction of an Algorithm the next
step is to determine the amount of resources
(complexity of algorithms).
 This step is called algorithm analysis.
 Two questions we always ask about
algorithm:
 Does it work correctly?
 How long does it take?
 The second question is not so obvious.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
4
 The efficiency of an algorithm:
 F (steps (time complexity), storage (space
complexity), Bandwidth (I/O complexity)).
 Run-time analysis:
 Theoretical classification that estimates
the increase in running time of an
algorithm as its input size increases.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
5
 Run-time efficiency is a topic of great
interest in computer science.
 A program can take seconds, hours or even
years to finish executing, depending on
which algorithm it implements.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
6
Growth Rate
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
7
Algorithm Analysis
 How can we say that one algorithm performs
better than another?
 Quantify the resources required to execute:
 Time
 Memory
 I/O / Bandwidth
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
8
 Algorithm analysis is used to:
 Estimate the running time, space, I/O.
 Reduce the running time.
 Framework to describe the running time.
 Correction of Algorithm.
 The relation of time of Algorithm with the
size of data.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
9
 Provides insight into designing efficient
Algorithms.
 Determine the bottlenecks.
 Develop efficient algorithm for a given
problem.
 Make better use of hardware.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
10
Model of Implementation
 For the analysis, we assume:
 A generic one-processor
 RAM model f computation
 Algorithms will be implemented as
computer programs.
 In the RAM model, instructions are executed
one after another (no concurrent operations)
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
11
Running Time Calculation
 The efficiency of an algorithm is estimated
by its performance.
 The performance of an algorithm can be
measured by the time, space & bandwidth
requirement.
 The time, space & bandwidth requirement of
an algorithm is called the computational
complexity of the algorithm.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
12
 The greater the amount of the time and space
required, the more complex is the algorithm.
 Which measure is more important?
 Normally we are concerned with the time rather
than space.
 The reasons are that:
 Firstly it becomes easier and cheaper to obtain
space.
 Secondly techniques to achieve space efficiency
by spending more time are available.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
13
Analysis Tools
 Running time is a natural measure of
goodness, since time is a precious resource.
 Computer solutions should run as fast as
possible.
 The running time is affected by:
 Hardware environment
 Software environment
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
14
Measuring Running Time
 Factors that affect running time:
 Machine
 Compiler
 Algorithm
 Input data
 CPU used by other processes (Garbage
collection)
 Therefore it is difficult to get precise
measurements.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
15
 The amount of time depends on the amount
of input.
 T = f(input size)
 The exact value of the function depends on:
 Speed of the host machine,
 The quality of the compiler,
 The quality of programs.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
16
 Analyzing an algorithm, time is not really a
number of seconds but the number of
operations.
 The number of operations is related to the
execution time, so we will use the word time
to describe an algorithm’s computational
complexity.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
17
The Experimental Approach
 The best way.
 But, there are some reasons which reject the
use of this method:
 We would like to eliminate the bad ones
early.
 This method does not enable you to reason
about whether the efficiency can be
improved.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
18
 This method does not give you any insight
into how the program will perform if run
on different hardware or under different
conditions.
 The effort involve program and testing.
 May be one Algorithm is not better
written.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
19
The Analytic Approach
 In theoretical approach the time complexity is the
number of steps.
 It characterizes running time as a function of the
input size.
 It takes into account all possible inputs.
 It allows us to evaluate the speed of an algorithm
independent of the hardware/software
environment.
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
20
 Using this method we can develop a general
way of analyzing the running times of
algorithms that:
 “Independent” of actual implementation
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
21
Summary
 In this presentation, we discussed:
 Algorithm Analysis
 Resources for analysis
 Experimental & analytical approach for
analysis
Algorithm Analysis
Algorithm
Analysis
&
Design April 2020
22
Exercises
 Explain by example the analysis of Algorithm
 What Resources are analyzed, which resource
is more important & why?
 Explain the difference between Experimental
& analytical approach.
End of Lesson 2
Questions?

More Related Content

Similar to Lesson num 2 - Algorithm Analysis - I.pptx (20)

PPTX
Chapter 1 Data structure.pptx
wondmhunegn
 
PPT
chapter 1
yatheesha
 
PDF
introduction to analysis of algorithm in computer science
tissandavid
 
PDF
Introduction to analysis algorithm in computer Science
tissandavid
 
PPTX
algorithmanalysisinfundamentalsofdatastructure-190810085243.pptx
ShirishaBuduputi
 
PPTX
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
PPTX
Design and analysis of algorithm lec 1.pptx
AyeshaIftikhar67
 
PDF
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
TechVision8
 
PPTX
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
PPTX
AoA Lec Design of algorithm spresentation
HamzaSadaat
 
PPTX
Lecture 11234567890qwertyuiodfghjdfgh.pptx
IfraLuqman
 
PPTX
Algorithm description in data structures
ananya195642
 
PPT
Chapter1.1 Introduction.ppt
Tekle12
 
PPT
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Tekle12
 
PDF
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
mtahanasir65
 
PPTX
Algorithm analysis (All in one)
jehan1987
 
PDF
Algorithms.pdf
OluwafolakeOjo
 
PPTX
Algorithms : Introduction and Analysis
Dhrumil Patel
 
PPSX
Data Structure and Algorithm Chapter 1.ppsx
SolomonEndalu
 
PPT
CSCI 4140-AA Lec_02.ppt
ZahidKhan671907
 
Chapter 1 Data structure.pptx
wondmhunegn
 
chapter 1
yatheesha
 
introduction to analysis of algorithm in computer science
tissandavid
 
Introduction to analysis algorithm in computer Science
tissandavid
 
algorithmanalysisinfundamentalsofdatastructure-190810085243.pptx
ShirishaBuduputi
 
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Design and analysis of algorithm lec 1.pptx
AyeshaIftikhar67
 
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
TechVision8
 
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
AoA Lec Design of algorithm spresentation
HamzaSadaat
 
Lecture 11234567890qwertyuiodfghjdfgh.pptx
IfraLuqman
 
Algorithm description in data structures
ananya195642
 
Chapter1.1 Introduction.ppt
Tekle12
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Tekle12
 
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
mtahanasir65
 
Algorithm analysis (All in one)
jehan1987
 
Algorithms.pdf
OluwafolakeOjo
 
Algorithms : Introduction and Analysis
Dhrumil Patel
 
Data Structure and Algorithm Chapter 1.ppsx
SolomonEndalu
 
CSCI 4140-AA Lec_02.ppt
ZahidKhan671907
 

Recently uploaded (20)

PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PDF
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
PPTX
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Introduction to Probability(basic) .pptx
purohitanuj034
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
Virus sequence retrieval from NCBI database
yamunaK13
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Basics and rules of probability with real-life uses
ravatkaran694
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Introduction to Probability(basic) .pptx
purohitanuj034
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
Ad

Lesson num 2 - Algorithm Analysis - I.pptx

  • 1. Algorithm Analysis Algorithm Analysis & Design April 2020 1 S. Hassan Adelyar, Ph.D Instructor of Computer Science Faculty Kabul University December 2020 Lesson II: Algorithm-Analysis Part I
  • 2. Algorithm Analysis Algorithm Analysis & Design April 2020 2 Learning Outcome  By the end of this presentation, students will be able to:  Analyze Algorithm  Identify the resources for analysis  Understand experimental approach for analysis  Understand the analytical approach for analysis
  • 3. Algorithm Analysis Algorithm Analysis & Design April 2020 3 Algorithm Analysis  After correction of an Algorithm the next step is to determine the amount of resources (complexity of algorithms).  This step is called algorithm analysis.  Two questions we always ask about algorithm:  Does it work correctly?  How long does it take?  The second question is not so obvious.
  • 4. Algorithm Analysis Algorithm Analysis & Design April 2020 4  The efficiency of an algorithm:  F (steps (time complexity), storage (space complexity), Bandwidth (I/O complexity)).  Run-time analysis:  Theoretical classification that estimates the increase in running time of an algorithm as its input size increases.
  • 5. Algorithm Analysis Algorithm Analysis & Design April 2020 5  Run-time efficiency is a topic of great interest in computer science.  A program can take seconds, hours or even years to finish executing, depending on which algorithm it implements.
  • 7. Algorithm Analysis Algorithm Analysis & Design April 2020 7 Algorithm Analysis  How can we say that one algorithm performs better than another?  Quantify the resources required to execute:  Time  Memory  I/O / Bandwidth
  • 8. Algorithm Analysis Algorithm Analysis & Design April 2020 8  Algorithm analysis is used to:  Estimate the running time, space, I/O.  Reduce the running time.  Framework to describe the running time.  Correction of Algorithm.  The relation of time of Algorithm with the size of data.
  • 9. Algorithm Analysis Algorithm Analysis & Design April 2020 9  Provides insight into designing efficient Algorithms.  Determine the bottlenecks.  Develop efficient algorithm for a given problem.  Make better use of hardware.
  • 10. Algorithm Analysis Algorithm Analysis & Design April 2020 10 Model of Implementation  For the analysis, we assume:  A generic one-processor  RAM model f computation  Algorithms will be implemented as computer programs.  In the RAM model, instructions are executed one after another (no concurrent operations)
  • 11. Algorithm Analysis Algorithm Analysis & Design April 2020 11 Running Time Calculation  The efficiency of an algorithm is estimated by its performance.  The performance of an algorithm can be measured by the time, space & bandwidth requirement.  The time, space & bandwidth requirement of an algorithm is called the computational complexity of the algorithm.
  • 12. Algorithm Analysis Algorithm Analysis & Design April 2020 12  The greater the amount of the time and space required, the more complex is the algorithm.  Which measure is more important?  Normally we are concerned with the time rather than space.  The reasons are that:  Firstly it becomes easier and cheaper to obtain space.  Secondly techniques to achieve space efficiency by spending more time are available.
  • 13. Algorithm Analysis Algorithm Analysis & Design April 2020 13 Analysis Tools  Running time is a natural measure of goodness, since time is a precious resource.  Computer solutions should run as fast as possible.  The running time is affected by:  Hardware environment  Software environment
  • 14. Algorithm Analysis Algorithm Analysis & Design April 2020 14 Measuring Running Time  Factors that affect running time:  Machine  Compiler  Algorithm  Input data  CPU used by other processes (Garbage collection)  Therefore it is difficult to get precise measurements.
  • 15. Algorithm Analysis Algorithm Analysis & Design April 2020 15  The amount of time depends on the amount of input.  T = f(input size)  The exact value of the function depends on:  Speed of the host machine,  The quality of the compiler,  The quality of programs.
  • 16. Algorithm Analysis Algorithm Analysis & Design April 2020 16  Analyzing an algorithm, time is not really a number of seconds but the number of operations.  The number of operations is related to the execution time, so we will use the word time to describe an algorithm’s computational complexity.
  • 17. Algorithm Analysis Algorithm Analysis & Design April 2020 17 The Experimental Approach  The best way.  But, there are some reasons which reject the use of this method:  We would like to eliminate the bad ones early.  This method does not enable you to reason about whether the efficiency can be improved.
  • 18. Algorithm Analysis Algorithm Analysis & Design April 2020 18  This method does not give you any insight into how the program will perform if run on different hardware or under different conditions.  The effort involve program and testing.  May be one Algorithm is not better written.
  • 19. Algorithm Analysis Algorithm Analysis & Design April 2020 19 The Analytic Approach  In theoretical approach the time complexity is the number of steps.  It characterizes running time as a function of the input size.  It takes into account all possible inputs.  It allows us to evaluate the speed of an algorithm independent of the hardware/software environment.
  • 20. Algorithm Analysis Algorithm Analysis & Design April 2020 20  Using this method we can develop a general way of analyzing the running times of algorithms that:  “Independent” of actual implementation
  • 21. Algorithm Analysis Algorithm Analysis & Design April 2020 21 Summary  In this presentation, we discussed:  Algorithm Analysis  Resources for analysis  Experimental & analytical approach for analysis
  • 22. Algorithm Analysis Algorithm Analysis & Design April 2020 22 Exercises  Explain by example the analysis of Algorithm  What Resources are analyzed, which resource is more important & why?  Explain the difference between Experimental & analytical approach.
  • 23. End of Lesson 2 Questions?