Hi everyone๐,

From the last post, Programming Concept - #Algorithm, I discussed what algorithm is and also gave an example. Now this post is not about Data Structure and Algorithm, yet!. The idea behind this series is to take you from the beginner level to advanced level in programming so make sure you stay tuned ๐ป.

Pseudo code as mentioned early is basically a false code. Computers understand only two vocabularies i.e. 0 and 1. For every programming language, there is a syntactic rule to follow but with pseudo code, you can write the code in your own language and that is the beauty of it.

Algorithm is all about performing a task and before doing any task, you must first understand what the task is. Every task has it's own requirements and there can be multiple ways to perform the same task.

Let's take look at an example;

The bus driver has this map to pick up the school kids from their home labeled A, B, C. Can you guess the shortest route to use from point A, B and C?

- School -> A -> B -> C -> School
- School -> C -> A -> B -> School
- School -> B -> A -> C -> School

Above are 3 possible options to visit all points. Can you pick out the "best" option? Of course, it will be the second option. Why? Because the driver might consider the using less fuel and shortest time. Though we have multiple options, we will always consider the most efficient one. Efficiency is one of the key characteristics of a good algorithm.

Let's write down the pseudo code for the first option:

- Start the bus ๐
- Move from School ๐๐ซ
- Go to Point A ๐ ๐
- Move from Point A ๐๐
- Go to Point B๐ก๐
- Move from Point B ๐๐ก
- Go to Point C ๐๐
- Move from Point C ๐๐
- Go to School ๐ซ๐
- Stop bus engine ๐

....and that's it. See how simple you can write down the pseudo code? And this can be used as a blueprint to write code in different programming language.

It's always good to write down the steps when solving a problem in the form of a pseudo code. You can then further break it down into smaller modules making your program easy to manage.

Key characteristics to note about pseudo code:

- All actions for each step must be doable.
- Each step must be precisely define with no ambiguity
- Each step of the algorithm must be finite i.e. it must have an end

Note that your algorithm must also have a starting point and the end point just as every program cannot run infinitely.

In the next article, I will discuss how to write the algorithm graphically using flow chart.

Have a great day ๐ and see you on the next one.

## Top comments (0)