# Everyone’s Algorithm

Algorithms are part of our Day to Day life activities. Even we don’t know the word algorithms but using them in real life.

In IT field every one came across with Algorithms in their career, They will get as interview question, they are part of designing various algorithms.

Freshers will get confuse of understanding Algorithms, Laterals will get confuse which algorithm need to use to solve the problem.

So much of having Algorithm, Algorithm….

# What is an Algorithm?

An Algorithm is a set of instructions to perform/complete an operation.

Example:

Steps to Drink Water:

1. Walk towards the water source
2. Reach to the Cup/Container
3. Take the Cup/Container to get water from Source
4. Fill Cup/Container with water from Source
5. Drink water

we can take this example to better understand about algorithms. to complete a task we need to complete above 5 instructions.

# How to Know Algorithm works?

Algorithms are sequential operations to solve the problem. To solve the problem we don’t need to follow one algorithm. There are multiple ways to solve the problem. To find out algorithm works or not we can check with some parameters.

Time and Space also takes vital roles in algorithms

Now we see the above example “ Drink water ” with additional Parameters

Solution 1 — Drink water from Water bottle

Solution 2 — Drink water from Tap

Solution 3 — Drink water from River

Solution 4 — Drink water from Mountain

Solution 5 — Drink water from Waterfall

Solution 6 — Drink water from Sea

The problem is same for all above solutions, “ Drink water from Water bottle ” will have very less number of operations compared to “ Drink water from Sea ” from above solutions.

# Good Algorithm ? Bad Algorithm ?

is your Algorithm good? or bad? we may come to this dilemma when we want to implement. Algorithm must follow some qualities to solve the problem in efficient way.

1. The input parameters and output should defined precisely.
2. Each step should be clear in algorithm to perform operation. it should not be vague or ambiguous.
3. Algorithm should be effective with different ways to solve a problem.
4. Algorithm doesn’t need to be write in programming language, It will be in simple sentences that any one can understand and use it any programming language.

# Example

The above 5 steps are Good enough to understand “How to Drink water”. Now we will extend these 5 steps with any one solution from the above. I will take “Drink water from River”.

Those 5 steps are good enough to Drink water but here River is the additional parameter. we need to add few more steps like, Check the reachability to get water, is Water enough clean to drink? if not we need to boil and drink.

Programming Example

Find the largest number from three numbers

`Step 1: StartStep 2: Declare a, b and c.Step 3: Read a, b and c.Step 4: If a > b           If a > c              Display a is the largest number.           Else              Display c is the largest number.        Else           If b > c              Display b is the largest number.           Else              Display c is the greatest number.  Step 5: Stop`

# Why We need Algorithms?

Algorithms are like a Treasure passing from one to other. It’s a knowledge transfer from one to other. Drinking water is simple task from above example. what if we don’t know how to drink, what if our parents doesn’t tell us?. we got this knowledge and we are using it.

Similar way to solve every problem there are some steps. if we don’t have any we try to create new one and passing that information to others to complete.

Thomas Alva Edison — “I have not failed. I’ve just found 10,000 ways that won’t work.”.

He tried 10,000 algorithms and finally he succeeded it. Now we are using the 10,001 algorithm directly.

To be Continued…

IVR Developer, Data Science enthusiast and Always Ready to Learn

## More from Nasreenkhan

IVR Developer, Data Science enthusiast and Always Ready to Learn

## Immutable classes in Java

Get the Medium app