Sunday, 30 April 2017

Classification by Implementation Method

  1. Recursive and Iterative


  • recursive algorithm is one that calls itself repeatedly until a base condition is satisfied.
  • Iterative algorithms use constructs like loops and sometimes other data structures like stacks and queues to solve the problems.

Some problems are suited for recursive and others are suited for iterative.


  1. Procedural or Declarative(non-procedural)



  • In declarative programming languages, we say what we want without having to say how to do it.
  • With procedural programming, we have to specify the exact steps to get the result.

For example, SQL is more declarative than procedural, because the queries don’t specify the steps to produce the result. Examples of procedural languages include: C, PHP, and PERL.


  1. Serial, Parallel or Distributed



  • The computers execute one instruction at a time. These are called serial algorithms. 
  • Parallel algorithms take advantage of computer architectures to process several instructions at a time. They divide the problem into subproblems and serve them to several processors or threads. Iterative algorithms are generally parallelizable. 
  • If the parallel algorithms are distributed on to different machines then we call such algorithms distributed algorithms.



  1. Deterministic or Non-Deterministic 



  • Deterministic algorithms solve the problem with a predefined process, 
  • whereas non – deterministic algorithms guess the best solution at each step through the use of heuristics.


  1. Exact or Approximate 



  • The algorithms for which we are able to find the optimal solutions are called exact algorithms. In computer science, if we do not have the optimal solution, we give approximation algorithms.
  • Approximation algorithms are generally associated with NP-hard problems



No comments:

Post a Comment

Array

Program for Array Rotation 1st Method - Using temp array  - Time complexity - O(n), Space - O(d) See algo and code 2nd Method - rotate...