Algorithm Analysis and Design: Introduction To Algorithms
Algorithm Analysis and Design: Introduction To Algorithms
INTRODUCTION TO ALGORITHMS
Algorithm & its properties, Time & Space complexity, Asymptotic Notations.
Algorithm & its properties
An algorithm is a sequence of computational steps that transforms
the input into the output.
An algorithm is a step by step procedure to solve a problem. It take
a set of value as input and produces some value as output. The
efficiency of an algorithm is based on the space and time
complexity.
Algorithm & its properties
Properties of an algorithm
Algorithms must contain finite number of steps
Algorithms must be precise and unambiguous.
Algorithm Design and Analysis
The efficiency or running time of an algorithm is stated as a function
relating the input length to the number of steps (time complexity) or
storage locations (space complexity).
Algorithm analysis provides theoretical estimates for the resources
needed by any algorithm which solves a given computational
problem.
Time & Space complexity
Space Complexity Time Complexity
Space Complexity is the space Time complexity is the time
(memory) needed for an algorithm required for an algorithm to
to solve the problem. An efficient complete its process. It allows
algorithm take space as small as comparing the algorithm to check
possible. which one is the efficient one.
Asymptotic Notations
When it comes to analyzing the complexity of any algorithm in terms
of time and space, we can never provide an exact number to define
the time required and the space required by the algorithm, instead
we express it using some standard notations, also known
as Asymptotic Notations
Example
Let us take an example, if some algorithm has a time complexity of T(n) =
(n2 + 3n + 4), which is a quadratic equation. For large values of n, the 3n +
4 part will become insignificant compared to the n2 part.
Also, When we compare the execution times of
two algorithms the constant coefficients of higher
order terms are also neglected.
An algorithm that takes a time of 200n2 will be
faster than some other algorithm that
takes n3 time, for any value of n larger than 200.
Since we're only interested in the asymptotic
behavior of the growth of the function, the
constant factor can be ignored too.
For n = 1000, n2 will be 1000000 while 3n + 4 will be 3004.
What is Asymptotic Behaviour