Algorithm and Complexity-2
Algorithm and Complexity-2
Algorithm Complexity
ALGORITHM
An algorithm is any well-define
computational procedure that takes some
values or set of values as input and
produces some values or set of values as
output
As a sequence of computational steps that
transforms the input into output
ALGORITHM COMPLEXITY
Analyzing an algorithm has come to means
predicting the resources that algorithm requires.
Such as memory, bandwidth but most often it is
computational time that we want to measure.
Space Complexity: Amount of memory space
required by the algorithm during the course of
its execution.
Time Complexity: Amount of time that algorithm
takes to execute. This is not really a number of
seconds or any other clock measurement but
rather an approximation of the number of
operations that an algorithm performs.
ANALYZING AN ALGORITHM
The actual number of operations done for some
specific size of input data set is not very
interesting nor it tells us very much.
Instead our analysis will determine an equation
that relates the number of operations that an
algo. Performs to size of input (GROWTH RATE)
We can compare two algorithms by comparing
the rate at which this equation grows.
There are instances where algo. ‘A’ may take
fewer operations than algo ‘B’ when input size
is very small but many more when input size
gets large.
COMPLEXITY