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.

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?

  1. Using Natural Language like English
  2. Flow chart
  3. Pseudo code Approach 

The algorithm to find whether the given number is even or odd using the natural language approach is shown below. 

  1. Ask the user to provide a number
  2. Do the modulus division by two
  3. Compare the result of modulus division with 0
  4. If the result is equal, then it is an even number
  5. 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.

Algorithm Specification A Pseudo code Approach 1
Algorithm Specification A Pseudo code Approach 1

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.