Definition:
Algorithm is ordered sequence of finite well defined,unambiguous instructions for completing a task
- Algorithm like a English.representation,which is used to solve the problem
- Step by step procedure for solving a task (or) Problem
Example:Find the greatest among three numbers:
Algorithm 1:
Step 1:Start
Step 2:Read the three numbers
Step 3:Compare A and B.if A is greater perform step 4 else perform step 5
Step 4:compare A and C. if A is greater,OUTPUT “B is Greatest” else OUTPUT “C is Greatest”. then Perform the Step 6
Step 5:Compare B and C.if B is greater,OUTPUT “B is Greatest” else OUTPUT ” C is Greatest”
Step 6:Stop
Algorithm 2:
Step 7:Start
Step 8: Read the three numbers A, B, C
Step 9:Compare A and B.If A is greater,Store A in MAX,else store B in MAX.
Step 10:Compare MAX and C.If MAX is Greater, OUTPUT “MAX is greatest” else OUTPUT “C is greatest”
Step 11: Stop
1) Algorithm:
Sequence of instructions that carry out in a step by step manner.
The algorithm is used to refer the logic of the program.
It is one of the basic tool used to develop the problem solving.
Characteristics:
Each & every instructions should be precise (perfect)
The instructions should not be repeated
Ensure that the algorithm will terminate
Qualities of good algorithm:
The following factors are considered & measure the good algorithm.
1) Time: lesser time will take to execute the program.
2) Memory: lesser memory will take to execute the program.
3) Accuracy: program more accurate results.
4) Sequence: it must form in a sequence.
5) Generality: it designed to handle a range of input data to meet criteria.
So that algorithm