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

PDF
251 - Alogarithms Lects.pdf
PPTX
Lesson 1 - Introduction to Algorithms.pptx
PPTX
Chapter 1 Data structure.pptx
PPTX
Chapter 09 design and analysis of algorithms
PPTX
Algorithm Development & Complexity Analysis.pptx
PPS
Data Structures and Algorithms Unit 01
PDF
A gentle introduction to algorithm complexity analysis
PDF
1.1 the introduction of design and analysis of algorithm
251 - Alogarithms Lects.pdf
Lesson 1 - Introduction to Algorithms.pptx
Chapter 1 Data structure.pptx
Chapter 09 design and analysis of algorithms
Algorithm Development & Complexity Analysis.pptx
Data Structures and Algorithms Unit 01
A gentle introduction to algorithm complexity analysis
1.1 the introduction of design and analysis of algorithm

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

PDF
Algorithm Analysis.pdf
PPT
Daa presentation 97
PPT
assignment character education assignment
PPTX
Software estimation techniques
PPTX
Daa unit 1
PPT
chapter 1
PPTX
Data structures algorithms basics
DOC
Program concep sequential statements
PPT
Data Structure and Algorithm chapter two, This material is for Data Structure...
PPTX
Introduction to Data Structure and algorithm.pptx
PPT
AOA Week 01.ppt
PDF
Introduction to data structure and algorithm
Ā 
PPTX
ADSA orientation.pptx
PDF
In computer sciencei
PPTX
Algorithms Data Structures - Algorithms Efficiency.pptx
PDF
IRJET- Machine Learning Techniques for Code Optimization
PPT
Lec1
PDF
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
PDF
Algo and flowchart
Algorithm Analysis.pdf
Daa presentation 97
assignment character education assignment
Software estimation techniques
Daa unit 1
chapter 1
Data structures algorithms basics
Program concep sequential statements
Data Structure and Algorithm chapter two, This material is for Data Structure...
Introduction to Data Structure and algorithm.pptx
AOA Week 01.ppt
Introduction to data structure and algorithm
Ā 
ADSA orientation.pptx
In computer sciencei
Algorithms Data Structures - Algorithms Efficiency.pptx
IRJET- Machine Learning Techniques for Code Optimization
Lec1
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
Algo and flowchart
Ad

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Ā 
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
BƀI Tįŗ¬P Bį»” TRỢ 4 KỸ NĂNG TIįŗ¾NG ANH 9 GLOBAL SUCCESS - Cįŗ¢ NĂM - BƁM SƁT FORM Đ...
PPTX
Lesson notes of climatology university.
Pharma ospi slides which help in ospi learning
O5-L3 Freight Transport Ops (International) V1.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
STATICS OF THE RIGID BODIES Hibbelers.pdf
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial diseases, their pathogenesis and prophylaxis
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O7-L3 Supply Chain Operations - ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Ā 
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Cell Types and Its function , kingdom of life
BƀI Tįŗ¬P Bį»” TRỢ 4 KỸ NĂNG TIįŗ¾NG ANH 9 GLOBAL SUCCESS - Cįŗ¢ NĂM - BƁM SƁT FORM Đ...
Lesson notes of climatology university.
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?