CSC 305 Lec1 - Analysis of Algorithms
CSC 305 Lec1 - Analysis of Algorithms
Introduction
Usually, the efficiency or running time of an algorithm is stated as a function relating the input
length to the number of steps, known as time complexity, or volume of memory, known
as space complexity. An algorithm is said to be efficient when this function's values are small,
or grow slowly compared to a growth in the size of the input. Different inputs of the same size
may cause the algorithm to have different behavior;
Exact (not asymptotic) measures of efficiency can sometimes be computed but they usually
require certain assumptions concerning the particular implementation of the algorithm,
called model of computation.
Algorithms are often quite different from one another, though the objective of these algorithms
are the same. For example, we know that a set of numbers can be sorted using different
algorithms. Number of comparisons performed by one algorithm may vary with others for the
same input. Hence, time complexity of those algorithms may differ. At the same time, we need to
calculate the memory space required by each algorithm.
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.
When carrying out the analysis, we will concentrate on the computation instructions and not
things such as networking tasks or user input and output. We will assume that the following
computation operations are executed as one instruction each:
• Assigning a value to a variable
• Looking up the value of a particular element in an array
• Comparing two values
• Incrementing a value
• Basic arithmetic operations such as addition, multiplication, etc.