Algorithm Specification A Pseudo code Approach
For Complete YouTube Video: Click Here
This class will try to understand Algorithm Specification A Pseudo code Approach.
We have already discussed the definition of an Algorithm in the previous class.
Table of Contents
Algorithm Specification A Pseudo code Approach
For example, assume that if we have a problem finding the given number is even or odd.
For that problem, we have to write an algorithm.
So far, we haven’t specified how to write an algorithm.
How to describe an algorithm?
- Using Natural Language like English
- Flow chart
- Pseudo code Approach
The algorithm to find whether the given number is even or odd using the natural language approach is shown below.
- Ask the user to provide a number
- Do the modulus division by two
- Compare the result of modulus division with 0
- If the result is equal, then it is an even number
- Else it is an odd number
We use simple English sentences to write an algorithm in the above approach.
Each step of the algorithm is explained in detail using the English language.
The image below represents how to describe an algorithm using a flow chart.
The flow chart approach is a pictorial way of representing an algorithm.
This approach is suitable for small or straightforward algorithms, but it is a complex process for big algorithms.
The third approach is the Pseudo Code approach.
The name itself states Pseudo means half code.
It uses the keywords or the syntax’s of any programming language.
The algorithm to find whether the given number is even or odd is shown below.
Algorithm EvenorOdd() { if(number%2 == 0) then print even; else print odd; }
We use this approach to write algorithms in the entire course.