# Algorithm and its properties

Learn: In this article, we are going to study about **what is algorithm and what are the different properties of an algorithm**? Why we use algorithm? What are the benefits of algorithm over code? What is pseudo code? What is the importance of algorithm in computer programming?

Submitted by Amit Shukla, on September 29, 2017

## What is an algorithm?

**An algorithm is an effective, efficient and best method which can be used to express solution of any problem within a finite amount of space and timeand in a well-defined formal language**. Starting from an initial state the instructions describe a process or computational process that, when executed, proceeds through a finitenumber of well-defined successive states, eventually producing "output"and terminating at a final ending state.

**In other words, we can say that**,

- Step by step procedure for solving any problem is known as algorithm.
- An algorithm is a finite set of instructions that, if followed, accomplishes a particular task.
- An algorithm is a sequence of computational steps that transform the input into a valuable or required output.
- Any special method of solving a certain kind of problem is known as algorithm.

**All Algorithms must satisfy the following criteria - **

**1) Input**

There are more quantities that are extremely supplied.**2) Output**

At least one quantity is produced.**3) Definiteness**

Each instruction of the algorithm should be clear and unambiguous.**4) Finiteness**

The process should be terminated after a finite number of steps.**5) Effectiveness**

Every instruction must be basic enough to be carried out theoretically or by using paper and pencil.

## Properties of Algorithm

Simply writing the sequence of instructions as an algorithm is not sufficient to accomplish certain task. It is necessary to have following properties associated with an algorithm.

**Non Ambiguity**

Each step in an algorithm should be non-ambiguous. That means each instruction should be clear and precise. The instruction in any algorithm should not denote any conflicting meaning. This property also indicates the effectiveness of algorithm.**Range of Input**

The range of input should be specified. This is because normally the algorithm is input driven and if the range of input is not being specified then algorithm can go in an infinite state.**Multiplicity**

The same algorithm can be represented into several different ways. That means we can write in simple English the sequence of instruction or we can write it in form of pseudo code. Similarly, for solving the same problem we can write several different algorithms.**Speed**

The algorithmis written using some specified ideas. Bus such algorithm should be efficient and should produce the output with fast speed.**Finiteness**

The algorithm should be finite. That means after performing required operations it should be terminate.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions