Engineer bro!

Wed Oct 06 2021 (2 months ago)

Engineer by mistake!

I am a software engineer by passion

What is the algorithm?

The algorithm is a finite set of well-defined sequential instructions to perform any task. In computer science and mathematics, algorithms are used to solve a class of specific problems or perform any sort of computation.

A simple real-life algorithm

A simple real-life algorithm could be making a cup of tea. You will not believe it but, making a tea is an algorithm where you have to follow some set of instructions in a sequential manner to get the final tea.

The algorithm for making a cup of tea can be described as follows

  1. Put the tea bag in a cup

  2. Fill the kettle with water

  3. Boil the water in the kettle

  4. Pour some of the boiled water into the cup

  5. Add milk to the cup

  6. Add sugar to the cup

  7. Stir the tea

  8. Drink the tea

You can see that we have to follow the 88 steps to get the fine tea. So, these steps can be said as the instruction and they need to follow in a sequential manner. Because you can not reach step 8 before step 1,2,3,..,71,2,3,..,7.

Property of an algorithm

  1. Input - The algorithm must have input values from some specified set.

  2. Output - The algorithm must provide output.

  3. Finiteness - The algorithm must terminate after a finite number of steps.

  4. Definiteness - All steps of the algorithm should be well defined.

  5. Effectiveness - It must possible to perform each step of the algorithm correctly in a finite amount of time.

The basic steps of an algorithm

  1. Read the input

  2. Process the input

  3. Produce the output

Algorithm vs Program

An algorithm is a set of well defined sequential instructions to perform any task, whereas programs are the code written in any programming language to be executed by the computer.

Representation of an algorithm

An algorithm can be represented in three ways.

  1. A set of instructions written in plain English

  2. Pseudocode

  3. Flow chart

Algorithm design technique

In general, for any problem, there could be many ways to solve them. The same thing applies to algorithms too, we have few design techniques as follows.

  1. Recursive algorithms

  2. Backtracking algorithms

  3. Branch and bound algorithms

  4. Brute force algorithms

  5. Greedy algorithms

  6. Divide and conquer algorithms

  7. Dynamic programming algorithms

  8. Randomized algorithms

Thanks for reading

Algotithmintroduction

Comments (0)

Discussions (0)


© 2021 dsabyte. All rights reserved