SlideShare a Scribd company logo
1 of 19
22CS404 ANALYSIS OF ALGORITHMS
UNIT I : INTRODUCTION TO ALGORITHM ANALYSIS
Introduction to Algorithm Analysis – Notion of Time and
Space Complexity – Algorithm efficiency – Asymptotic
Notations – Recurrence Relations – Solving Recurrence
equations - Iteration Method, Recurrence Tree Method
and Master’s Theorem - Mathematical analysis for
Recursive and Non-recursive algorithms - Empirical
analysis of algorithm. Brute Force Approach: General
Approach – Algorithm Analysis –Applications.
INTRODUCTION
• An algorithm is an effective method for finding out the
solution for a given problem. It is a sequence of
instruction. That conveys the method to address a
problem
• Algorithm : Step by step procedure to solve a
computational problem is called Algorithm.
or
• An Algorithm is a step-by-step plan for a
computational procedure that possibly begins with an
input and yields an output value in a finite number of
steps in order to solve a particular problem.
INTRODUCTION
• An algorithm is a set of steps of operations to solve a
problem performing calculation, data processing, and
automated reasoning tasks.
• An algorithm is an efficient method that can be
expressed within finite amount of Time and space.
• The important aspects of algorithm design include
creating an efficient algorithm to solve a problem in
an efficient way using minimum time and space.
• To solve a problem, different approaches can be
followed. Some of them can be efficient with respect
to time consumption, whereas other approaches may
be memory efficient.
Properties of Algorithm
To Evaluate An Algorithm we have to Satisfy the following
Criteria:
1. INPUT: The Algorithm should be given zero or more input.
2. OUTPUT: At least one quantity is produced. For each input the
algorithm produced value from specific task.
3. DEFINITENESS: Each instruction is clear and unambiguous.
4. FINITENESS: If we trace out the instructions of an algorithm,
then for all cases, the algorithm terminates after a finite
number of steps.
5. EFFECTIVENESS: Every instruction must very basic so that it
can be carried out, in principle, by a person using only pencil
& paper.
Difference between Algorithm, Pseudocode
and Program
Algorithm : Systematic logical approach which is a
well-defined, step-by-step procedure that allows a
computer to solve a problem.
Pseudocode : It is a simpler version of a programming
code in plain English which uses short phrases to write
code for a program before it is implemented in a specific
programming language.
Program : It is exact code written for problem following
all the rules of the programming language.
Differences
Algorithm Program
1.At design phase 1.At Implementation phase
2.Natural language 2.written in any
programming language
3.Person should have 3.Programmer
Domain knowledge
4.Analyze 4.Testing
Algorithm can be described (Represent) in four
ways.
1.Natural language like English:
When this way is chooses, care should be taken, we
should ensure that each & every statement is definite.
(no ambiguity)
2. Graphic representation called flowchart:
This method will work well when the algorithm is small&
simple.
3. Pseudo-code Method:
In this method, we should typically describe algorithms as
program, which resembles language like Pascal & Algol
(Algorithmic Language).
4.Programming Language:
we have to use programming language to write algorithms like
Algorithm Specification
How To Write an Algorithm
Step-1:start Step-1: start
Step-2:Read a,b,c Step-2: Read a,b,c
Step-3:if a>b Step-3:if a>b then go to step 4
if a>c otherwise go to step 5
print a is largest Step-4:if a>c then
else print a is largest otherwise
if b>c print c is largest
print b is largest Step-5: if b>c then
else print b is largest otherwise
print c is largest print c is largest
Step-4 : stop step-6: stop
PSEUDO-CODE CONVENTIONS
1. Comments begin with // and continue until the end of line.
2. Blocks are indicated with matching braces { and }.
3. An identifier begins with a letter. The data types of variables
are not explicitly declared.
node= record
{
data type 1 data 1;
data type n data n;
node *link;
}
4. There are two Boolean values TRUE and FALSE.
Logical Operators
AND, OR, NOT
Relational Operators
<, <=,>,>=, =, !=
5. Assignment of values to variables is done using the
assignment statement. <Variable>:= <expression>;
6. Compound data types can be formed with records. Here is an
example,
Node. Record
{
data type – 1 data-1;
.
.
.
data type – n data – n;
node * link;
}
Here link is a pointer to the record type node. Individual data
items of a record can be accessed with  and period.
PSEUDO-CODE CONVENTIONS (Cont…)
…
7. The following looping statements are employed.
For, while and repeat-until While Loop:
While < condition > do
{
<statement-1>
..
..
<statement-n>
}
For Loop:
For variable: = value-1 to value-2 step step do
{
<statement-1>
.
.
.
<statement-n>
}
PSEUDO-CODE CONVENTIONS (Cont…)
repeat-until:
repeat
<statement-1>
.
.
.
<statement-n>
until<condition>
8. A conditional statement has the following forms.
 If <condition> then <statement>
 If <condition> then <statement-1>
Else <statement-1>
PSEUDO-CODE CONVENTIONS (Cont…)
Case statement:
Case
{
: <condition-1> : <statement-1>
.
.
.
: <condition-n> : <statement-n>
: else : <statement-n+1>
}
9. Input and output are done using the instructions read &
write. No format is used to specify the size of input or output
quantities
PSEUDO-CODE CONVENTIONS (Cont…)
10. There is only one type of procedure: Algorithm, the heading
takes the form, Algorithm Name (Parameter lists)
consider an example, the following algorithm fields &
returns the maximum of n given numbers:
1. algorithm Max(A,n)
2. // A is an array of size n
3. {
4. Result := A[1];
5. for i:= 2 to n do
6. if A[i] > Result then
7. Result :=A[i];
8. return Result;
9. }
PSEUDO-CODE CONVENTIONS (Cont…)
Issue in the study of algorithm
1. How to create an algorithm.
2. How to validate an algorithm.
3. How to analyses an algorithm
4. How to test a program.
1.How to create an algorithm: To create an
algorithm we have following design technique
a) Divide & Conquer
b) Greedy method
c) Dynamic Programming
d) Branch & Bound
e) Backtracking
Issue in the study of algorithm (Cont…)
2.How to validate an algorithm:
Once an algorithm is created it is necessary to show that it
computes the correct output for all possible legal input , this
process is called algorithm validation.
3.How to analyses an algorithm:
Analysis of an algorithm or performance analysis refers to task
of determining how much computing Time & storage
algorithms required.
a) Computing time-Time complexity: Frequency or Step count
method
b) Storage space- To calculate space complexity we have to use
number of input used in algorithms.
Issue in the study of algorithm (Cont…)
Issue in the study of algorithm (Cont…)
4.How to test the program:
Program is nothing but an expression for the algorithm using
any programming language. To test a program we need
following
a) Debugging: It is processes of executing programs on sample
data sets to determine whether faulty results occur & if so
correct them.
b) Profiling or performance measurement is the process of
executing a correct program on data set and measuring the
time & space it takes to compute the result.
Need of Algorithm
1.To understand the basic idea of the problem.
2.To find an approach to solve the problem.
3.To improve the efficiency of existing techniques.
4.To understand the basic principles of designing the algorithms.
5.To compare the performance of the algorithm with respect to
other techniques.
6.It is the best method of description without describing the
implementation detail.
7.The Algorithm gives a clear description of requirements and
goal of the problem to the designer.
8.A good design can produce a good solution.
9.To understand the flow of the problem.

More Related Content

Similar to 01 Introduction to analysis of Algorithms.pptx

2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdfishan743441
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit onessuserb7c8b8
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxchandankumar364348
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Dr. Pankaj Agarwal
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESHarshJha34
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - IntroductionMadhu Bala
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.NandiniSidana
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps workingSaurabh846965
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptxRahikAhmed1
 

Similar to 01 Introduction to analysis of Algorithms.pptx (20)

DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptx
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - Introduction
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 

Recently uploaded

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 

Recently uploaded (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 

01 Introduction to analysis of Algorithms.pptx

  • 1. 22CS404 ANALYSIS OF ALGORITHMS UNIT I : INTRODUCTION TO ALGORITHM ANALYSIS Introduction to Algorithm Analysis – Notion of Time and Space Complexity – Algorithm efficiency – Asymptotic Notations – Recurrence Relations – Solving Recurrence equations - Iteration Method, Recurrence Tree Method and Master’s Theorem - Mathematical analysis for Recursive and Non-recursive algorithms - Empirical analysis of algorithm. Brute Force Approach: General Approach – Algorithm Analysis –Applications.
  • 2. INTRODUCTION • An algorithm is an effective method for finding out the solution for a given problem. It is a sequence of instruction. That conveys the method to address a problem • Algorithm : Step by step procedure to solve a computational problem is called Algorithm. or • An Algorithm is a step-by-step plan for a computational procedure that possibly begins with an input and yields an output value in a finite number of steps in order to solve a particular problem.
  • 3. INTRODUCTION • An algorithm is a set of steps of operations to solve a problem performing calculation, data processing, and automated reasoning tasks. • An algorithm is an efficient method that can be expressed within finite amount of Time and space. • The important aspects of algorithm design include creating an efficient algorithm to solve a problem in an efficient way using minimum time and space. • To solve a problem, different approaches can be followed. Some of them can be efficient with respect to time consumption, whereas other approaches may be memory efficient.
  • 4. Properties of Algorithm To Evaluate An Algorithm we have to Satisfy the following Criteria: 1. INPUT: The Algorithm should be given zero or more input. 2. OUTPUT: At least one quantity is produced. For each input the algorithm produced value from specific task. 3. DEFINITENESS: Each instruction is clear and unambiguous. 4. FINITENESS: If we trace out the instructions of an algorithm, then for all cases, the algorithm terminates after a finite number of steps. 5. EFFECTIVENESS: Every instruction must very basic so that it can be carried out, in principle, by a person using only pencil & paper.
  • 5. Difference between Algorithm, Pseudocode and Program Algorithm : Systematic logical approach which is a well-defined, step-by-step procedure that allows a computer to solve a problem. Pseudocode : It is a simpler version of a programming code in plain English which uses short phrases to write code for a program before it is implemented in a specific programming language. Program : It is exact code written for problem following all the rules of the programming language.
  • 6. Differences Algorithm Program 1.At design phase 1.At Implementation phase 2.Natural language 2.written in any programming language 3.Person should have 3.Programmer Domain knowledge 4.Analyze 4.Testing
  • 7. Algorithm can be described (Represent) in four ways. 1.Natural language like English: When this way is chooses, care should be taken, we should ensure that each & every statement is definite. (no ambiguity) 2. Graphic representation called flowchart: This method will work well when the algorithm is small& simple. 3. Pseudo-code Method: In this method, we should typically describe algorithms as program, which resembles language like Pascal & Algol (Algorithmic Language). 4.Programming Language: we have to use programming language to write algorithms like Algorithm Specification
  • 8. How To Write an Algorithm Step-1:start Step-1: start Step-2:Read a,b,c Step-2: Read a,b,c Step-3:if a>b Step-3:if a>b then go to step 4 if a>c otherwise go to step 5 print a is largest Step-4:if a>c then else print a is largest otherwise if b>c print c is largest print b is largest Step-5: if b>c then else print b is largest otherwise print c is largest print c is largest Step-4 : stop step-6: stop
  • 9. PSEUDO-CODE CONVENTIONS 1. Comments begin with // and continue until the end of line. 2. Blocks are indicated with matching braces { and }. 3. An identifier begins with a letter. The data types of variables are not explicitly declared. node= record { data type 1 data 1; data type n data n; node *link; } 4. There are two Boolean values TRUE and FALSE. Logical Operators AND, OR, NOT Relational Operators <, <=,>,>=, =, !=
  • 10. 5. Assignment of values to variables is done using the assignment statement. <Variable>:= <expression>; 6. Compound data types can be formed with records. Here is an example, Node. Record { data type – 1 data-1; . . . data type – n data – n; node * link; } Here link is a pointer to the record type node. Individual data items of a record can be accessed with  and period. PSEUDO-CODE CONVENTIONS (Cont…)
  • 11. … 7. The following looping statements are employed. For, while and repeat-until While Loop: While < condition > do { <statement-1> .. .. <statement-n> } For Loop: For variable: = value-1 to value-2 step step do { <statement-1> . . . <statement-n> } PSEUDO-CODE CONVENTIONS (Cont…)
  • 12. repeat-until: repeat <statement-1> . . . <statement-n> until<condition> 8. A conditional statement has the following forms.  If <condition> then <statement>  If <condition> then <statement-1> Else <statement-1> PSEUDO-CODE CONVENTIONS (Cont…)
  • 13. Case statement: Case { : <condition-1> : <statement-1> . . . : <condition-n> : <statement-n> : else : <statement-n+1> } 9. Input and output are done using the instructions read & write. No format is used to specify the size of input or output quantities PSEUDO-CODE CONVENTIONS (Cont…)
  • 14. 10. There is only one type of procedure: Algorithm, the heading takes the form, Algorithm Name (Parameter lists) consider an example, the following algorithm fields & returns the maximum of n given numbers: 1. algorithm Max(A,n) 2. // A is an array of size n 3. { 4. Result := A[1]; 5. for i:= 2 to n do 6. if A[i] > Result then 7. Result :=A[i]; 8. return Result; 9. } PSEUDO-CODE CONVENTIONS (Cont…)
  • 15. Issue in the study of algorithm 1. How to create an algorithm. 2. How to validate an algorithm. 3. How to analyses an algorithm 4. How to test a program.
  • 16. 1.How to create an algorithm: To create an algorithm we have following design technique a) Divide & Conquer b) Greedy method c) Dynamic Programming d) Branch & Bound e) Backtracking Issue in the study of algorithm (Cont…)
  • 17. 2.How to validate an algorithm: Once an algorithm is created it is necessary to show that it computes the correct output for all possible legal input , this process is called algorithm validation. 3.How to analyses an algorithm: Analysis of an algorithm or performance analysis refers to task of determining how much computing Time & storage algorithms required. a) Computing time-Time complexity: Frequency or Step count method b) Storage space- To calculate space complexity we have to use number of input used in algorithms. Issue in the study of algorithm (Cont…)
  • 18. Issue in the study of algorithm (Cont…) 4.How to test the program: Program is nothing but an expression for the algorithm using any programming language. To test a program we need following a) Debugging: It is processes of executing programs on sample data sets to determine whether faulty results occur & if so correct them. b) Profiling or performance measurement is the process of executing a correct program on data set and measuring the time & space it takes to compute the result.
  • 19. Need of Algorithm 1.To understand the basic idea of the problem. 2.To find an approach to solve the problem. 3.To improve the efficiency of existing techniques. 4.To understand the basic principles of designing the algorithms. 5.To compare the performance of the algorithm with respect to other techniques. 6.It is the best method of description without describing the implementation detail. 7.The Algorithm gives a clear description of requirements and goal of the problem to the designer. 8.A good design can produce a good solution. 9.To understand the flow of the problem.