KEMBAR78
Algorithm - Introduction | PPTX
 What is algorithm?
 Characteristics of algorithm
 Design method
ALGORITHM
 An algorithm is a finite set of instructions that if followed,
accomplishes a particular task.
 An input to an algorithm specifies an instance of the
problem.
 An algorithm can be specified in a natural language or
pseudo code.
 Algorithm can be implemented as computer programs.
algorithm
PROBLEM
ALGORITHM
COMPUTERINPUT OUTPUT
NOTATION OF ALGORITHM
 INPUT: zero or more quantities externally supplied.
 OUTPUT: at least one quantity is produced.
 DEFINITENESS: Each instruction is clear and ambiguous.
 FINITENESS: the algorithm terminates after a finite number of
steps.
 EFFICIENCY: every instruction must be very basic.
 UN AMBIGUITY: an algorithm must be expressed in a fashion
that is completely free for ambiguity.
Characteristics of algorithm
1. Understanding the problem.
2. Ascertaining the capabilities of computational device.
3. Choosing between exact and approximate problem solving.
4. Deciding the appropriate data structure.
5. Algorithm design techniques.
6. Method of specifying an algorithm.
7. Proving an algorithm’s correctness.
8. Analyzing an algorithm.
9. Coding an algorithm.
DESIGN METHODS
UNDERSTAND THE PROBLEM
DECIDING ON COMPUTATIONAL
EXACT VS APPOROXIMATE
DATA STRUCTURE
DESIGN TECHNIQUES
DESIGN AN ALGORITHM
PROVE CORRECTNESS
ANALYZE THE ALGORITHM
CODE THE ALGORITHM
 Reading the problem’s description carefully.
 Ask questions and clarify the doubt arise in the problem.
 Do some examples and the think about special cases.
 Divide the problem into smaller problems until it become
manageable size.
1.Understanding the problem
 In random access machine, instruction to be executed one
after another, one operation at a time.
 Algorithm designed to be executed on such machines are
called sequential algorithm.
 The central assumption of the RAM model does not called
for some new computers that can execute operations
concurrently. That is operation executed parallel.
 Algorithm that take the advantage of operations that
executed concurrently is called parallel algorithm
2.Ascertaing capabilities of a computational device
The next principal decision is to choose between solving the
problem exactly or solving the problem approximately.
 Exact algorithm: solve the problem exactly .
 Appropriate algorithm: solve the problem approximately.
3. Choosing between exact and approximate problem
solving
 Some problem can not be solved exactly
- extracting square root
- solving non linear equations
- evaluating definite integrals
 Exact algorithm can be slow because of the problem’s complexity.
- traveling salesman problem of finding the shortest path
through n cities
 It is a part of more sophisticated algorithm that solves a problem
exactly
BENEFITS OF
APPROXIMATE ALGORITHM
 defined as a particular scheme of organizing related data items.
 Algorithm + Data structure = Programs.
 Important for both design and analysis of algorithms
 Some algorithm do not demand any ingenuity is representing
their inputs.
 Some of the algorithm design techniques is used to structuring
or restricting data specifying a problem’s instance.
 The variability is algorithm is due to in which the data of
program are stored.
4.Deciding the appropriate data structure.
An algorithm design technique is a general approach to solving
problems algorithmically that is applicable to a variety of
problems from different areas of computing
Merits:
 Provide guidance for designing algorithms for new problem.
 Algorithm are the cornerstone of computer science.
 Used to classify the algorithm based on the design idea.
 can serve as a natural way to both categorize and study
algorithms.
5. algorithm design technique
There are three options that are most widely used for
specifying algorithms.
 Euclid’s algorithm
 Pseudo code
 Flow chart
6. METHOD OF SPECIFYING
AN ALGORITHM
1. Euclid’s algorithm:
 specified by simple English statement.
 step by step form
2. Flow chart:
 It is a method of expressing an algorithm by
diagrammatic representation.
 It is very simple.
6. METHOD OF SPECIFYING AN
ALGORITHM (Cont.)
3. Pseudo code:
 It is a mixture of natural language and programming
language constructs.
 It is move precise than a natural language.
 For simplicity, declaration of the variable omitted.
 For, if and while statements are used to show the scope
of variables.
 “  ” is used for assignment operation.
 “// ” is used for comments
6. METHOD OF SPECIFYING
AN ALGORITHM (cont.)
 Once an algorithm has been specified, then its correctness
must be proved.
 The algorithm yields a required result for every legitimate
input in a finite amount of time.
 Proving correctness - mathematical induction.
 In mathematical induction an algorithms iteration provide a
natural sequence of steps needs for proofs.
 The notation of correctness for approximation is less
straight forward than it is for exact algorithm
7.Proving an algorithm’s correctness
• Efficiency of an algorithm can be measured in terms of
space and time.
• Space:
The number of units, it requires for memory storage.
• Time:
The amount of time needed for executing an algorithm.
Complexity of an algorithm is measured by calculating
the time taken, space required for performing the algorithm.
8.Analyzing algorithms
 Once an algorithm has been selected, a 10-506 speed up may
be worth an effort.
 An algorithm’s optimally is not about the efficiency of an
algorithm but about the complexity of the problem.
 Another important issue of algorithmic problem solving is the
question of whether or not every problem can be solved by
algorithm.
9. Coding an algorithm

Algorithm - Introduction

  • 1.
     What isalgorithm?  Characteristics of algorithm  Design method ALGORITHM
  • 2.
     An algorithmis a finite set of instructions that if followed, accomplishes a particular task.  An input to an algorithm specifies an instance of the problem.  An algorithm can be specified in a natural language or pseudo code.  Algorithm can be implemented as computer programs. algorithm
  • 3.
  • 4.
     INPUT: zeroor more quantities externally supplied.  OUTPUT: at least one quantity is produced.  DEFINITENESS: Each instruction is clear and ambiguous.  FINITENESS: the algorithm terminates after a finite number of steps.  EFFICIENCY: every instruction must be very basic.  UN AMBIGUITY: an algorithm must be expressed in a fashion that is completely free for ambiguity. Characteristics of algorithm
  • 5.
    1. Understanding theproblem. 2. Ascertaining the capabilities of computational device. 3. Choosing between exact and approximate problem solving. 4. Deciding the appropriate data structure. 5. Algorithm design techniques. 6. Method of specifying an algorithm. 7. Proving an algorithm’s correctness. 8. Analyzing an algorithm. 9. Coding an algorithm. DESIGN METHODS
  • 6.
    UNDERSTAND THE PROBLEM DECIDINGON COMPUTATIONAL EXACT VS APPOROXIMATE DATA STRUCTURE DESIGN TECHNIQUES DESIGN AN ALGORITHM PROVE CORRECTNESS ANALYZE THE ALGORITHM CODE THE ALGORITHM
  • 7.
     Reading theproblem’s description carefully.  Ask questions and clarify the doubt arise in the problem.  Do some examples and the think about special cases.  Divide the problem into smaller problems until it become manageable size. 1.Understanding the problem
  • 8.
     In randomaccess machine, instruction to be executed one after another, one operation at a time.  Algorithm designed to be executed on such machines are called sequential algorithm.  The central assumption of the RAM model does not called for some new computers that can execute operations concurrently. That is operation executed parallel.  Algorithm that take the advantage of operations that executed concurrently is called parallel algorithm 2.Ascertaing capabilities of a computational device
  • 9.
    The next principaldecision is to choose between solving the problem exactly or solving the problem approximately.  Exact algorithm: solve the problem exactly .  Appropriate algorithm: solve the problem approximately. 3. Choosing between exact and approximate problem solving
  • 10.
     Some problemcan not be solved exactly - extracting square root - solving non linear equations - evaluating definite integrals  Exact algorithm can be slow because of the problem’s complexity. - traveling salesman problem of finding the shortest path through n cities  It is a part of more sophisticated algorithm that solves a problem exactly BENEFITS OF APPROXIMATE ALGORITHM
  • 11.
     defined asa particular scheme of organizing related data items.  Algorithm + Data structure = Programs.  Important for both design and analysis of algorithms  Some algorithm do not demand any ingenuity is representing their inputs.  Some of the algorithm design techniques is used to structuring or restricting data specifying a problem’s instance.  The variability is algorithm is due to in which the data of program are stored. 4.Deciding the appropriate data structure.
  • 12.
    An algorithm designtechnique is a general approach to solving problems algorithmically that is applicable to a variety of problems from different areas of computing Merits:  Provide guidance for designing algorithms for new problem.  Algorithm are the cornerstone of computer science.  Used to classify the algorithm based on the design idea.  can serve as a natural way to both categorize and study algorithms. 5. algorithm design technique
  • 13.
    There are threeoptions that are most widely used for specifying algorithms.  Euclid’s algorithm  Pseudo code  Flow chart 6. METHOD OF SPECIFYING AN ALGORITHM
  • 14.
    1. Euclid’s algorithm: specified by simple English statement.  step by step form 2. Flow chart:  It is a method of expressing an algorithm by diagrammatic representation.  It is very simple. 6. METHOD OF SPECIFYING AN ALGORITHM (Cont.)
  • 15.
    3. Pseudo code: It is a mixture of natural language and programming language constructs.  It is move precise than a natural language.  For simplicity, declaration of the variable omitted.  For, if and while statements are used to show the scope of variables.  “  ” is used for assignment operation.  “// ” is used for comments 6. METHOD OF SPECIFYING AN ALGORITHM (cont.)
  • 16.
     Once analgorithm has been specified, then its correctness must be proved.  The algorithm yields a required result for every legitimate input in a finite amount of time.  Proving correctness - mathematical induction.  In mathematical induction an algorithms iteration provide a natural sequence of steps needs for proofs.  The notation of correctness for approximation is less straight forward than it is for exact algorithm 7.Proving an algorithm’s correctness
  • 17.
    • Efficiency ofan algorithm can be measured in terms of space and time. • Space: The number of units, it requires for memory storage. • Time: The amount of time needed for executing an algorithm. Complexity of an algorithm is measured by calculating the time taken, space required for performing the algorithm. 8.Analyzing algorithms
  • 18.
     Once analgorithm has been selected, a 10-506 speed up may be worth an effort.  An algorithm’s optimally is not about the efficiency of an algorithm but about the complexity of the problem.  Another important issue of algorithmic problem solving is the question of whether or not every problem can be solved by algorithm. 9. Coding an algorithm