A typical programming task can be divided into two phases:
· Problem solving phase
· produce an ordered sequence of steps that describe solution of problem
· this sequence of steps is called an algorithm
· Implementation phase
· Implement the program in some programming language
Algorithm:
An algorithm is a sequence of statements which is used to solve a problem. While writing algorithm we have to consider statements of different types as given below:
- Input statements
- Executable statements
- Storage statements
- Output statements
In most of the cases, we are combining Executable and storage statements as we are using assignment statements.
An algorithm should possess the following characteristics:
- Each and every instruction should be precise and clear
- Each instruction should be performed a finite number of times
- The algorithm should ultimately terminate
- When the algorithm terminates the desired result should be obtained.
Advantages of Algorithm:
- Very easy to write
- Easy techniques to understand Logic.
- It is a step-wise representation of a solution to a given problem, which makes it easy to understand.
- An algorithm uses a definite procedure.
- It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge.
- Every step in an algorithm has its own logical sequence so it is easy to debug.
- By using algorithm, the problem is broken down into smaller pieces or steps hence, it is easier for programmer to convert it into an actual program
Disadvantages of Algorithm:
- Writing algorithm takes a long time.
- Difficult to show branching and looping in the algorithm.
- Big tasks are difficult to put in to algorithm.
No comments:
Post a Comment