Complex Anlysis
Complex Anlysis
INTRO
Complexity Analysis has as aim to evaluate the
variation of execution time. It is also known as
computational complexity theory and has its roots in the
early 20th centuries.
DEFINITION
Complexity Analysis is the process of determining the
amount of time or space and algorithm requires as the
size of the input size increases. It can be defined as a
technique used to characterize the time taken by an
algorithm with respect to input size.
WHY DO WE NEED DATA COMPLEXITY?
-It determines the amount of time and space
`required to execute.
-It helps determine the difficulty of a problem.
-It helps optimize the most critical parts of codes
-It helps in the identification of different algorithms
TYPES OF COMPLEXITY MEASURES
There are 3 types of complex analysis. They are meant to
show how complexity of an algorithm is measured they
are;
-Time Complexity: It is defined as for the algorithm to run
as a function of the length of the input. It’s expressed
using the big O notation, focusing on the dominant terms
as the input size approaches infinity.
~ O(1) Constant Time: The algorithm runtime remains
constant regardless the input size. The algorithm
performs a fixed number of operations, irrespective of
how much data it’s processing.
~ O(log n) Logarithm time: The runtime grows
logarithmically with the input size. This typically occurs
when the algorithm repeatedly divides the input size.
~O(n) Linear Time: The runtime grows linearly with the
input size. The algorithm processes each element in the
input once.
~O(2^n) Exponential Time: The runtime doubles with
each addition to the input size. These algorithms become
impractical even for moderate size inputs.
~O(n!) Factorial Time: The runtime grows factorially with
the input size. These algorithms are extremely inefficient
and only feasible for very small input.
-Space Complexity: The amount of memory an algorithm
uses as the size of the input increases. It’s also expressed
using the big O notation. This includes both the space
used for storing the input data and auxiliary space used
during the algorithm’s execution.
~ Common Space complexities: Similar to the time
complexity space can be O(1), O(log n), O(n),O(2^e) etc.
~ In-place Algorithm: Algorithms with O(1) space
complexities are called In-place algorithm because they
use a constant amount of extra space regardless of the
input size.