Here, We will learn why every programmer should learn introduction to algorithms, categories of algorithms, characteristics of algorithms, how to write algorithms with help of examples like write algorithm for the addition of two numbers.

**What are algorithms?**

**Algorithms **are a series of steps or rules for solving a computational problem.

In other words, an **algorithm **a step-by-step procedure which defines a set of instructions to be executed in a certain order to get the desired output.

**Example Code:**

```
if (clock.getTime() == 7am){
coffeeMaker.boilWater();
if (water.isBoiled()){
coffeeMaker.addCoffee();
coffeeMaker.pourCoffee();
}
}
else{
coffeeMaker.doNothing();
}
```

Code language: C++ (cpp)

A good algorithms is like using right and efficient tool in workshop.

**Example: **Using wrong algorithms mean cutting paper with a saw or trying to cut a piece of plywood with knife.

**Categories of Algorithms**

**Search –**Algorithm to search an item. Ex- Searching Techniques**Sort –**Algorithm to sort items in a certain order. Ex – Sorting Algorithms**Insert –**Algorithm to insert item.**Update –**Algorithm to update an existing item.**Delete –**Algorithm to delete an existing item.

**Characteristics of an Algorithm**

Not all procedure can be called an algorithm.

An algorithm should have the following characteristics:

**Unambiguous –**Each of its step and their inputs/outputs should be clear and must lead to only one meaning**Input –**Should have 0 or more well-defined inputs**Output –**should have 1 or more desirable well-defined outputs.**Finiteness –**must terminate after a finite number of steps.**Feasibility –**Should be feasible with the available resources.**Independent –**Should have step-by-step directions and independent of any programming language.

**How to Write an Algorithm?**

There is no well defined standard for writing algorithms. Algorithms are never written in support of a particular programming code.

We write algorithms in a step-by-step manner. Algorithms writing is a process and is executed after the problem domain is well-defined.

**Write algorithm for addition of two numbers and display the result.**

```
step 1 - START
step 2 - declare three integers a, b &c
step 3 - define values of a & b
step 4 - add values of a & b
step 5 - store output of step 4 to c
step 6 - print c
step 7 - STOP
```

Code language: C++ (cpp)

Algorithms tell the programmers how to code the program. Alternatively, the algorithm can be written as :

```
step 1 - START ADD
step 2 - get values of a & b
step 3 - c โ a + b
step 4 - display c
step 5 - STOP
```

Code language: C++ (cpp)

In design and analysis of algorithms, usually the second method is used to describe an algorithm.

We design algorithms to get a solution to a given problem. A problem can be solved in more than one ways.

### Related :

#### Insertion Sort

Here, We will learn about insertion sort in C, their algorithm, implementation code in C,…

#### Depth First Search (DFS)

Here, We will discuss about Depth First Search (DFS), their algorithms and also explain advantages,…

#### Shell Sort

Here, We will discuss about Shell Sort in C, their algorithm, implementation code in C,…

#### Asymptotic Analysis and Notation

#### Divide and Conquer Algorithms

Here, We will discuss about divide and conquer algorithms, their strategy, pros and cons of…

#### Sorting Algorithms

Here, We will learn about sorting algorithms, why is sorting necessary, classification and complexity of…

*Want to Contribute*:-

If you like “**To The Innovation**” and want to contribute, you can mail your articles to ๐ง **contribute@totheinnovation.com**. See your articles on the main page and help other coders.๐