“An algorithm is defined as finite sequence of explicit instructions that, when provided with a set of input values produces an output and then terminates.”
In algorithm, after a finite number of steps, a solution of the problem is achieved. Algorithm can have steps that repeat (iterate) or require decisions (logic and comparison) until task is completed.
Different algorithms may accomplish the same task, with a different set of instructions, in more or less the same time, space and efforts.
S.No. | Factors | Quality of good Algorithm |
| 1. | Time | To execute a program, the computer system takes some amount of time. The lesser the time taken, the better the algorithm is. |
| 2. | Memory | To execute a program, computer system takes some amount of memory storage. The lesser the memory required the better the algorithm is. |
| 3. | Accuracy | Multiple algorithms may provide suitable or correct solutions to a given problem, some of these may provide more accurate results than others, and such algorithms may be suitable. |
| 4. | Sequence | The procedure of an algorithm must be in a sequence and some of the instructions of an algorithm may be repeated number of times until a particular condition is met. |
| 5. | General Ability | The designed algorithm solves a single isolated problem and more often algorithms are designed to handle a range of input data to meet these criteria, so the algorithms must be generalized. |
| 1. | Normal English | The Algorithms can be easily represented in step by step sequential order in normal English, such algorithms are easy to understand, write and read. |
| 2. | Flowchart | The flowchart is a pictorial representation of an algorithm i.e. the sequential steps in an algorithm can be represented as flowchart using the standard symbols. |
| 3. | Pseudocode | Pseudocode is also a formal decision tool utilized very well with the rules of structured design and programming. |
| 4. | Decision Table | A decision table helps a lot in designing a specific segment of a design. |
| 5. | Program | The algorithms can be represented as a program using any high level language that becomes a program. |
Example 1: Algorithm to find the area and circumference of the Circle.
Step 1: Start
Step 2: Read the radius
Step 3:Find the area and the circumference of the circle using the formula
area<--3.14*r*r
circumference<--2*3.14*r
Step 4:Print the area and circumference of the circle
Step 5: Stop
Example 2: Algorithm to find the largest of three numbers A, B and C.
Step 1: Start
Step 2: Read three numbers say A,B,C.Find the larger number between A and B
and store it in MAX_AB.
Step 4: Find the larger number between MAX_AB and C and store it in MAX
Step 5:Display MAX
Step 6: Stop
8:42 AM
sdsd
Subscribe
Follow me!