# What is the complexity of an algorithm?

In this blog post(The complexity of an algorithm), I am going to discuss the complexity of an algorithm. An algorithm is a procedure that indicates the body of your program for a specific task.

We will explore how the complexity of an algorithm is calculated. What is the asymptotic complexity of an algorithm? What do you mean by complexity?|The complexity of an algorithm|

In computer science, the study of algorithms is a big and important task. There could be many algorithms to complete one task but to check the efficiency of the algorithm we can have various criteria to measure the efficiency of our algorithm.|The complexity of an algorithm|

To understand the complexity of an algorithm let’s take an example, Suppose P is an algorithm and q is the size of input data. The time and space taken by the algorithm P are the main measures for the efficiency of P.

The main key operations like the searching and sorting algorithms help to identify the time for executing a specific operation, such as the number of comparisons in finding a specific element.

In the same manner, space is measured by counting the maximum memory taken by an algorithm in terms of size q input data. In general, the space required by an algorithm is multiple of input data size q.

## What are the types of complexity of an algorithm?

The complexity of an algorithm is broadly classified into two types:

Space complexity
Time complexity

#### Space complexity:

Space complexity can be defined as space cover-up by a program for its completion. This space is a sum of multiple components explained below.

A fixed part contains a space for the code, space for a simple variable, and a fixed-size component variable, space for contents, etc.

A variable part is reserved for the variable component whose size depends on the particular problem instance being solved and the stack space used by the recursive procedure.

The space requirement s(p) of any program P can be written as :

s(P) = c+sP
Where c denotes the constant and sp indicates the instance characteristic

#### Time Complexity:

The time complexity is defined as the time to run a program for its completion.

The time T(p) taken by a program P is the summation of run time and compile time. The compile time does not depend on the instance characteristics. So only the run time of a program is going to matter, which is denoted by Tp.

You can also go through a few more amazing blog links below related to Data Structure:

## Conclusion:

The complexity of an algorithm is concerned with the time and space taken by that algorithm to complete a specific task. time complexity is the total time taken by the program to complete a task and space complexity is the total space covered by the program to complete the task. So the algorithm depends on the time and space taken by it.

Using this blog(The Complexity of an Algorithm) we have gone through how the complexity of an algorithm is calculated. What is the asymptotic complexity of an algorithm? What do you mean by complexity? What is the need to measure the complexity of an algorithm, and the Time complexity of algorithms?

In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post complexity of an algorithm along with its type of time complexity and space complexity.

Please feel free to give your important feedback in the comment section below.

Have a great time! Sayonara!

#### Anurag

I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.