0% found this document useful (0 votes)
11 views

Complexity of An Algorithm

Uploaded by

sayan.pal.23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Complexity of An Algorithm

Uploaded by

sayan.pal.23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Design Analysis and Algorithm

Topperworld.in

Complexity of an algorithm

• The complexity of an algorithm refers to the efficiency of the algorithm in


terms of the resources it consumes, such as time and space, as a function
of the input size.

• The analysis of algorithmic complexity helps in comparing and selecting


algorithms for solving a particular problem.
• Generally, we aim for algorithms with lower time and space complexity,
as they tend to be more efficient and scalable.
• It's important to note that there is a distinction between the worst-case,
best-case, and average-case complexities.

• While big O notation typically represents the worst-case scenario, other


notations like big Omega (Ω) and big Theta (Θ) can be used to describe
the lower bound and tight bounds, respectively.

There are two main types of algorithmic complexity:

Time Complexity.

Space Complexity.

©Topperworld
Design Analysis and Algorithm

❖ Time Complexity :

• Time complexity is defined in terms of how many times it takes to run


a given algorithm, based on the length of the input.
• Time complexity is not a measurement of how much time it takes to
execute a particular algorithm because such factors as programming
language, operating system, and processing power are also considered.
• Time complexity is a type of computational complexity that describes
the time required to execute an algorithm.

• The time complexity of an algorithm is the amount of time it takes for


each statement to complete.

• As a result, it is highly dependent on the size of the processed data.

• It also aids in defining an algorithm's effectiveness and evaluating its


performance.

• Time complexity is commonly expressed using big O notation (e.g.,


O(n), O(n^2), O(log n)), where n is the size of the input.

❖ Space Complexity :

• When an algorithm is run on a computer, it necessitates a certain


amount of memory space.

• The amount of memory used by a program to execute it is represented


by its space complexity.

©Topperworld
Design Analysis and Algorithm

• Because a program requires memory to store input data and temporal


values while running, the space complexity is auxiliary and input space.

• It also has best case, average case, and worst case scenarios, often
expressed using big-O notation.

Common time complexities (from best to worst):

▪ O(1) - Constant time


▪ O(log n) - Logarithmic time
▪ O(n) - Linear time
▪ O(n log n) - Linearithmic time
▪ O(n^2) - Quadratic time
▪ O(2^n) - Exponential time

Time and Space complexity of an Algorithm — simplified with examples

©Topperworld

You might also like