SlideShare a Scribd company logo
1 of 25
INTRODUCTION TO ALGORITHM ANALYSIS
AND DESIGN
BY
MEGHA V
RESEARCH SCHOLAR
KANNUR UNIVERSITY
CONTENTS
•INTRODUCTION
•DEFINITION OF ALGORITHMS
•ALGORITHM SPECIFICATION
•ANALYSIS OF ALGORITHMS
•ASYMPTOTIC NOTATIONS
INTRODUCTION
•The word algorithm comes from the name of Persian author, Abu Ja’far
Mohammed ibn Musa al Khowarizmi, who wrote a textbook on mathematics.
•Algorithm” refer to a method that can be used by a computer for the solution of
a problem.
Definition of Algorithms
Definition: An algorithm is a finite set of unambiguous instruction that if
followed accomplishes a particular task
• An algorithm should have finite number of steps
• It should accept Input and produce desired output
• Algorithm should terminate
An algorithm should satisfy the following
criteria
• Input: Algorithm should have Zero or more inputs
• Output: The algorithm should produce correct output
• Definiteness: Each instruction should be clear and unambiguous.
• Finiteness: The algorithm must terminate after finite number of steps.
• Effectiveness: The instructions should be simple and should transform given
input to desired output
• A program is an expression of algorithm in a programming language
Algorithm Specification
• We can use natural languages like English
• Graphic representation is called flow chart
• Another representation is Pseudocode that resembles C or Pascal
1. Comments begin with //
2. Blocks are indicated with matching braces {
}
3. An identifier begins with a letter
4. Simple data types like integer, char, float,
Boolean(True or False) can be used
5. Assignment of values to variables is done
using the assignment statement
< variable> :=<expression> or
< variable> <expression>
6. Logical operators (and, or, not )and the
relational operators <, ≤, =,≠,>, ≥ are
provided
Algorithm Specification
7. The following looping statements are employed:
for, while, repeat-until
8. The following conditional statements can be
used
If……. Then….
if …….then……else……
9. Array indices starts at zero, array elements are
represented using [] eg: A[i]
10. Inputs and outputs are done using the
instructions read and write
11. There is only one procedure: Algorithm
the heading takes the form
Algorithm Name ( parameter list)
While loop
While<condition>do
{
<statement 1>
…………….
…………….
<statement n>
}
While<variable<=n>do
{
<statement 1>
…………….
…………….
<statement n>
variable:=variable + incr
}
For loop
for variable:=value1 to value2 [step stepval]do
{
<statement 1>
………..
………..
<statement n>
}
Repeat-until loop
Repeat
{
<statement 1>
………..
………..
<statement n>
}Until<condition>
Condition
Conditional statements can be given in two
forms
If<condition> then
<statements>
If<condition> then
<statement 1>
else
<statement 2>
selection
Case statement
Case
{ :<condition 1> :<statement 1>
:
:<condition n> :<statement n>
:else :<statement n+1>
}
How to Analyze Algorithms
• Analysis of Algorithm or performance analysis refers to the task of determining
how much computing time and storage an algorithm requires.
• It involves 2 phases
1.Priori analysis
2.Posterior analysis
• Priori analysis: Algorithms computing time is obtained in terms of order of
magnitude
• Posterior analysis: Statistics about the algorithm in terms of space and time is
obtained during execution
• This is a challenging area which some times requires great mathematical skill
Testing
Testing consists of two phases
• Debugging:
- The process of executing the program on sample data sets and verify if
correct results are obtained.
• Profiling or performance measurement
- The process of executing a correct program on data set and measuring the
time and space it take to compute the result
Analysis of algorithms
Efficiency of algorithm depends on
1.Space efficiency
2.Time efficiency
Space Efficiency: It is the amount of memory required to run the program
completely and efficiently.
Space complexity depends on:
- Program space: space required to store the compiled program.
- Data space: Space required to store the constants variables.
Stack space: Space required to store return address , parameters passed etc.
Time complexity
• The time T(P) taken by a program is the sum of the compile time and runtime.
• We may assume that a compiled program will run several times without
recompilation
• Consequently we consider only the run time of the program. This runtime is
denoted as tp. .
Contd..
Time efficiency: Measure of how fast algorithm executes
Time complexity depends on:
• Speed of computer
• Choice of programming language
• Compiler used
• Choice of algorithm
• Number of inputs/outputs
• Operations count and Steps count
Time efficiency mainly depends on size of input n, hence expressed in terms of n.
Order of growth
The efficiency of algorithm can be analyzed by considering highest order of n.
Asymptotic notations
Asymptotic notations are used to compare the order of growth of algorithms.
The three notations used are
1. Big oh (O) notation
2. Big omega ( ) notation
3. Big theta ( )notation
Big O
Big-O, commonly written as O, is an Asymptotic Notation for the worst case, or ceiling of growth
for a given function.
A function t (n) is said to be in O(g(n)), denoted t (n) ∈ O(g(n)),
if t (n) is bounded above by some constant multiple of g(n) for all large n,
i.e., if there exist some positive constant c
and some nonnegative integer n0 such that
t (n) ≤ cg(n) for all n ≥ n0.
Big-Omega
•commonly written as Ω, is an Asymptotic Notation for the best case, or a floor growth rate for a
given function.
• It provides us with an asymptotic lower bound for the growth rate of runtime of an algorithm.
•A function t (n) is said to be in Ω(g(n)), denoted t (n) ∈ Ω(g(n)),
if t (n) is bounded below by some positive constant
multiple of g(n) for all large n, i.e., if there exist some
positive constant c and some nonnegative integer n0
Such that
t (n) ≥ cg(n) for all n ≥ n0.
Big Theta:
•A function t (n) is said to be in θ(g(n)), denoted t (n) ∈ θ(g(n)),
if t (n) is bounded both above and below by some positive constant multiples of
g(n) for all large n, i.e., if there exist some positive constants c1 and c2 and some
nonnegative integer n0 such that
c2g(n) ≤ t (n) ≤ c1g(n) for all n ≥ n0
REFERENCES
• ‘Introduction to The Design and Analysis of Algorithms’, Anany Levitin, 3rd Edn,
Pearson education

More Related Content

What's hot

daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 

What's hot (20)

daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Basics & asymptotic notations
Basics & asymptotic notationsBasics & asymptotic notations
Basics & asymptotic notations
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
Space complexity
Space complexitySpace complexity
Space complexity
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Introduction to Approximation Algorithms
Introduction to Approximation AlgorithmsIntroduction to Approximation Algorithms
Introduction to Approximation Algorithms
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 

Similar to Algorithm analysis and design

01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
ssuser586772
 

Similar to Algorithm analysis and design (20)

2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
 
Lecture 03 algorithm analysis
Lecture 03 algorithm analysisLecture 03 algorithm analysis
Lecture 03 algorithm analysis
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
 
DSA
DSADSA
DSA
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
Unit 2 algorithm
Unit   2 algorithmUnit   2 algorithm
Unit 2 algorithm
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpall...
Algorithm Class at KPHB  (C, C++ Course Training Institute in KPHB, Kukatpall...Algorithm Class at KPHB  (C, C++ Course Training Institute in KPHB, Kukatpall...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpall...
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
 

More from Megha V

More from Megha V (20)

Soft Computing Techniques_Part 1.pptx
Soft Computing Techniques_Part 1.pptxSoft Computing Techniques_Part 1.pptx
Soft Computing Techniques_Part 1.pptx
 
JavaScript- Functions and arrays.pptx
JavaScript- Functions and arrays.pptxJavaScript- Functions and arrays.pptx
JavaScript- Functions and arrays.pptx
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expression
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Python programming -Tuple and Set Data type
Python programming -Tuple and Set Data typePython programming -Tuple and Set Data type
Python programming -Tuple and Set Data type
 
Python programming –part 7
Python programming –part 7Python programming –part 7
Python programming –part 7
 
Python programming Part -6
Python programming Part -6Python programming Part -6
Python programming Part -6
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
 
Python programming- Part IV(Functions)
Python programming- Part IV(Functions)Python programming- Part IV(Functions)
Python programming- Part IV(Functions)
 
Python programming –part 3
Python programming –part 3Python programming –part 3
Python programming –part 3
 
Parts of python programming language
Parts of python programming languageParts of python programming language
Parts of python programming language
 
Python programming
Python programmingPython programming
Python programming
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm Analysis
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
UGC NET Paper 1 ICT Memory and data
UGC NET Paper 1 ICT Memory and data  UGC NET Paper 1 ICT Memory and data
UGC NET Paper 1 ICT Memory and data
 
Seminar presentation on OpenGL
Seminar presentation on OpenGLSeminar presentation on OpenGL
Seminar presentation on OpenGL
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Algorithm analysis and design

  • 1. INTRODUCTION TO ALGORITHM ANALYSIS AND DESIGN BY MEGHA V RESEARCH SCHOLAR KANNUR UNIVERSITY
  • 2. CONTENTS •INTRODUCTION •DEFINITION OF ALGORITHMS •ALGORITHM SPECIFICATION •ANALYSIS OF ALGORITHMS •ASYMPTOTIC NOTATIONS
  • 3. INTRODUCTION •The word algorithm comes from the name of Persian author, Abu Ja’far Mohammed ibn Musa al Khowarizmi, who wrote a textbook on mathematics. •Algorithm” refer to a method that can be used by a computer for the solution of a problem.
  • 4. Definition of Algorithms Definition: An algorithm is a finite set of unambiguous instruction that if followed accomplishes a particular task • An algorithm should have finite number of steps • It should accept Input and produce desired output • Algorithm should terminate
  • 5. An algorithm should satisfy the following criteria • Input: Algorithm should have Zero or more inputs • Output: The algorithm should produce correct output • Definiteness: Each instruction should be clear and unambiguous. • Finiteness: The algorithm must terminate after finite number of steps. • Effectiveness: The instructions should be simple and should transform given input to desired output • A program is an expression of algorithm in a programming language
  • 6. Algorithm Specification • We can use natural languages like English • Graphic representation is called flow chart • Another representation is Pseudocode that resembles C or Pascal
  • 7. 1. Comments begin with // 2. Blocks are indicated with matching braces { } 3. An identifier begins with a letter 4. Simple data types like integer, char, float, Boolean(True or False) can be used 5. Assignment of values to variables is done using the assignment statement < variable> :=<expression> or < variable> <expression> 6. Logical operators (and, or, not )and the relational operators <, ≤, =,≠,>, ≥ are provided Algorithm Specification
  • 8. 7. The following looping statements are employed: for, while, repeat-until 8. The following conditional statements can be used If……. Then…. if …….then……else……
  • 9. 9. Array indices starts at zero, array elements are represented using [] eg: A[i] 10. Inputs and outputs are done using the instructions read and write 11. There is only one procedure: Algorithm the heading takes the form Algorithm Name ( parameter list)
  • 10. While loop While<condition>do { <statement 1> ……………. ……………. <statement n> } While<variable<=n>do { <statement 1> ……………. ……………. <statement n> variable:=variable + incr }
  • 11. For loop for variable:=value1 to value2 [step stepval]do { <statement 1> ……….. ……….. <statement n> }
  • 13. Condition Conditional statements can be given in two forms If<condition> then <statements> If<condition> then <statement 1> else <statement 2>
  • 14. selection Case statement Case { :<condition 1> :<statement 1> : :<condition n> :<statement n> :else :<statement n+1> }
  • 15. How to Analyze Algorithms • Analysis of Algorithm or performance analysis refers to the task of determining how much computing time and storage an algorithm requires. • It involves 2 phases 1.Priori analysis 2.Posterior analysis • Priori analysis: Algorithms computing time is obtained in terms of order of magnitude • Posterior analysis: Statistics about the algorithm in terms of space and time is obtained during execution • This is a challenging area which some times requires great mathematical skill
  • 16. Testing Testing consists of two phases • Debugging: - The process of executing the program on sample data sets and verify if correct results are obtained. • Profiling or performance measurement - The process of executing a correct program on data set and measuring the time and space it take to compute the result
  • 17. Analysis of algorithms Efficiency of algorithm depends on 1.Space efficiency 2.Time efficiency Space Efficiency: It is the amount of memory required to run the program completely and efficiently. Space complexity depends on: - Program space: space required to store the compiled program. - Data space: Space required to store the constants variables. Stack space: Space required to store return address , parameters passed etc.
  • 18. Time complexity • The time T(P) taken by a program is the sum of the compile time and runtime. • We may assume that a compiled program will run several times without recompilation • Consequently we consider only the run time of the program. This runtime is denoted as tp. .
  • 19. Contd.. Time efficiency: Measure of how fast algorithm executes Time complexity depends on: • Speed of computer • Choice of programming language • Compiler used • Choice of algorithm • Number of inputs/outputs • Operations count and Steps count Time efficiency mainly depends on size of input n, hence expressed in terms of n.
  • 20. Order of growth The efficiency of algorithm can be analyzed by considering highest order of n.
  • 21. Asymptotic notations Asymptotic notations are used to compare the order of growth of algorithms. The three notations used are 1. Big oh (O) notation 2. Big omega ( ) notation 3. Big theta ( )notation
  • 22. Big O Big-O, commonly written as O, is an Asymptotic Notation for the worst case, or ceiling of growth for a given function. A function t (n) is said to be in O(g(n)), denoted t (n) ∈ O(g(n)), if t (n) is bounded above by some constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some nonnegative integer n0 such that t (n) ≤ cg(n) for all n ≥ n0.
  • 23. Big-Omega •commonly written as Ω, is an Asymptotic Notation for the best case, or a floor growth rate for a given function. • It provides us with an asymptotic lower bound for the growth rate of runtime of an algorithm. •A function t (n) is said to be in Ω(g(n)), denoted t (n) ∈ Ω(g(n)), if t (n) is bounded below by some positive constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some nonnegative integer n0 Such that t (n) ≥ cg(n) for all n ≥ n0.
  • 24. Big Theta: •A function t (n) is said to be in θ(g(n)), denoted t (n) ∈ θ(g(n)), if t (n) is bounded both above and below by some positive constant multiples of g(n) for all large n, i.e., if there exist some positive constants c1 and c2 and some nonnegative integer n0 such that c2g(n) ≤ t (n) ≤ c1g(n) for all n ≥ n0
  • 25. REFERENCES • ‘Introduction to The Design and Analysis of Algorithms’, Anany Levitin, 3rd Edn, Pearson education