Recents in Beach

Algorithm

Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.




Characteristics of An Algorithm:

There are five important characteristics of an algorithm that should be considered while designing any algorithm for any problem.



  1. Fineness: An algorithm should terminate infinite number of steps and each step must finish in finite amount of time.
  2. Definiteness (No Ambiguity): Each step of algorithm should be clearly and precisely define and there should not be any ambiguity. Example: A program fragment is given below:
    x ← 1.
    toss a coin, if the result is head then x← 3 else x ← 4.
    In the above program, all the steps would be carried out effectively but there is no definiteness since there are two possible values of x i.e., 1 and 3/4
  3. Inputs: An algorithm must have zero or more but must be finite number of inputs. Example of zero input algorithm. Print the ASCII code of each of the letter in the alphabet of the computer system.
  4. Output: An algorithm must have at-least one desirable outcome, i.e., output.
  5. Effectiveness: An algorithm should be effective. Effective means that each step should be referred as principle and should be executing in finite time.

Post a Comment

0 Comments