Algorithms in Programming
What is an Algorithms ?
An algorithm is a well defined step-by-step solution or a series of instructions to solve the problem.
Algorithms are the building blocks for programming and they allow things like computer , smart phones and websites to operate and make decision. An algorithm is a finite list of sequential steps specifying actions that if performed result in solution of a specific problem.
History of Algorithm
The world algorithm comes from the name of the 9th century Persian Muslim mathematician Abu Abdullah Muhammad ibn Musa Al-Khwarizmi.
The world algorism originally referred only to the rules of performing arithmetic using Hindu-Arabic numerals but evolved via European Latin translation of Al-Khwarizmi´s name into algorithm by the 18th century.
The use of the word evolved to include all definite procedures for solving problems or performing tasks.
Steps in Programming an Algorithm
Step 1 - Defining the problem
Step 2 - Planning the solution
Step 3 - Coding the program
Step 4 - Testing the program
Step 5 - Documenting the program
Representation of Algorithms
A computer program follows an algorithm , represented by a pseudocode or flow chart.
| (Problem-Pseudocode-Flowchart) |
Flow chart
Graphical or Symbolic representation for rendering steps in algorithm.
Each symbol has a specific meaning containing a short description of a step.
The flowchart symbols are linked together with arrows showing flow direction.
Pseudocode
Contains short English phrases used to describe steps in the algorithm.
Start with start or begin and ends with stop or end.
Flow chart Logic structure
Important Characteristics of an Algorithm
An algorithm is well ordered.
An algorithm has effectively computable operations.
An algorithm has unambiguous operations.
An algorithm produces a result.
An algorithm halts in a finite amount of time.
Properties of a Good Algorithm
Input specified
Input must be clearly specified in an algorithm where we need to know all relevant details like input data type, input size, data structure, input distribution etc. It can be a value or some set of values input.
Output specified
Output must be clearly specified in an algorithm where we need to know all relevant details related to the output. It can be a value or some set of values input or there is no such value.
Correctness
For every set of inputs our algorithm must halt with the correct output. In other words, our algorithm must be correct. The incorrect algorithm might halt with incorrect answers or not halt at the correct output for some input.
Efficiency
A computer maybe very fast but it cant be infinitely fast and similarly. a memory may be available easily but it is not for free. both are bounded resources and our algorithms must use them wisely.
Finiteness
Our algorithm must terminate after a finite set of instructions. we should always avoid infinite recursion or infinite loop condition.
Simple and elegant
An algorithm should be eassy to understand and implement.
Comments
Post a Comment