Design & Analysis of Algorithm
Design & Analysis of Algorithm
Analysis of
Algorithm
By Khuram Chattha
Algorithm
In this context, if we compare bubble sort and merge sort. Bubble sort
does not require additional memory, but merge sort requires additional
space. Though time complexity of bubble sort is higher compared to
merge sort, we may need to apply bubble sort if the program needs to
run in an environment, where memory is very limited.
Complexities of an Algorithm
The complexity of an algorithm computes the amount of time and
spaces required by an algorithm for an input of size (n). The complexity
of an algorithm can be divided into two types. The time
complexity and the space complexity.
1. Time Complexity of an Algorithm
The time complexity is defined as the process of determining a formula
for total time required towards the execution of that algorithm. This
calculation is totally independent of implementation and programming
language.
2. Space Complexity of an Algorithm
Space complexity is defining as the process of defining a formula for
prediction of how much memory space is required for the successful
execution of the algorithm. The memory space is generally considered
as the primary memory.
Rate of Growth
Rate of growth is defined as the rate at which the running time of the
algorithm is increased when the input size is increased.
The growth rate could be categorized into two types:
linear and exponential. If the algorithm is increased in a linear way
with an increasing in input size, it is linear growth rate. And if the
running time of the algorithm is increased exponentially with the
increase in input size, it is exponential growth rate.