Different Types of Algorithms in Data Structure.

What is Algorithm?

An Algorithm is a sequence of steps that describe how a problem can be solved. Every computer program that ends with a result is basically based on an Algorithm. These can also be used to solve mathematical problems and on many matters of day-to-day life. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.

The Algorithm are different Categories which are described as below:

  1. Search − Algorithm to search an item in a data structure.

  2. Sort − Algorithm to sort items in a certain order.

  3. Insert − Algorithm to insert item in a data structure.

  4. Update − Algorithm to update an existing item in a data structure.

  5. Delete − Algorithm to delete an existing item from a data structure.

These are the categories by which every problem become easy and can easily solved.

How to Write an Algorithm?

here are no well-defined standards for writing algorithms. Rather, it is problem and resource dependent. Algorithms are never written to support a particular programming code.

As we know that all programming languages share basic code constructs like loops (do, for, while), flow-control (if-else), etc. These common constructs can be used to write an algorithm.

We write algorithms in a step-by-step manner, but it is not always the case. Algorithm writing is a process and is executed after the problem domain is well-defined. That is, we should know the problem domain, for which we are designing a solution.


Let's try to learn algorithm-writing by using an example.

Problem − Design an algorithm to add two numbers and display the result.

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