What is Algorithm? Know How Easy it is to Write Your First Algorithm

It's very possible that you've heard this word before possibly in your primary education classes. This article is just a revise to your knowledge, because it makes your first entry into the programming world. Algorithms help you get into the big world of problem solving. Every business every problem needs some solutions and algorithms are where to help us. Before you begin programming, you must know what algorithms are and this article will help you knowing this at least from nothing to something.


Algorithm is a process of step-by-step execution of specific instruction to get a specific task done. Algorithms are everywhere, just look around every solved problem in this world gets to a solution in structured manners. From the beginning of this world, we humans are busy in try to solve all the mysteries. As we come to solve any mystery or problem, we have a tradition to write down the steps that took us to the solution, so we won't need to start over again. There are many examples can be given to you for algorithms, just for instance, a recipe for making tea is an algorithm for making tea or sorting some data and so on. Take a look to the list of steps below, to know how simply we can write algorithm. 


Algorithm for making tea for three peoples:

1- Take an empty pot and three cups.
2- Fill pot with water
3- Add three spoons of sugar into the pot
4- Add three half-fill cups of milk
5- Add three tea spoons in the pot
6- Boil the pot for 10 minutes
7- Tea is ready to serve!



How many ways I can write algorithms?

As you come into the programming world, you'll be given tasks to solve the problems programmatically. But before moving into programming you'll first have to clear a picture on how to attack the problem in order to get to a solution programmatically. It is advised to you work on algorithms first before you start coding. Before starting, traditionally you have you have two methods of writing algorithms, above method is famously known as pseudo-code. Other method is writing algorithm graphically using flowcharts (it will be discussed later)

Now let's come into the field of programming a little with just trying to write algorithms. Let's take an example for counting apples in a bag. We can write an algorithm for counting apples like this:

  1. Take a name AppleCount as a number starting from 0
  2. Put one apple out of the bag
  3. Add 1 into the AppleCount number
  4. Repeat step 2 and 3 until no apple found


As said earlier, we take some starting points before attacking to problems so an algorithm should have a starting point. In algorithm, you'll mostly work through body, conditions and repetitions, these terms in programming known as variables, conditions, loops/iteration. Always try to simplify your algorithms by keeping these things in your mind. If we try to further simplify above algorithm then step 4 can be split into two because it has condition. Let's have a look again:

  1. Take a name AppleCount as number starting from 0
  2. Put one apple out of the bag
  3. Add 1 into the AppleCount number
  4. Check if there is any apple found (Condition)
  5. Repeat from step 2

You're definitely thinking about what are conditions, iterations. They are very common things in our daily life, condition, your dad said if you pass your programming course, I will buy a high-tech computer for you? did you get you've conditions either true or false. Repetition simply repeating a predefined step over an over again.


Now you're on your way to start writing algorithms yourself. Are you ready to start writing algorithms of any predefined routine of your life??? If yes, then just write an algorithm for counting cars in garage or algorithm on how-to fry an egg. As you're ready, just post your first algorithm here on this page, I will give my full appreciation

Comments

Popular posts from this blog

How HTML Forms Works with JavaScript and Optimize Your Productivity with JQuery

My Mission

How to Use JavaScript to Do Calculation and Make Decisions in Your Website???…