Week 1 - Module 1 - Introduction To Algorithms and Complexity
Week 1 - Module 1 - Introduction To Algorithms and Complexity
Objectives :
● Define algorithm
● Identify the criteria of an algorithm
● Differentiate time and space complexity
● Characterize the size of the input of an algorithm
Analysis of algorithms
Algorithm analysis is an important part of computational complexities. The complexity
theory provides the theoretical estimates for the resources needed by an algorithm to solve
any computational task. Analysis of the algorithm is the process of analyzing the
problem-solving capability of the algorithm in terms of the time and size required (the size of
memory for storage while implementation). However, the main concern of the analysis of the
algorithm is the required time or performance.
Complexities of an Algorithm
Choosing the fastest algorithm for a certain task requires that you can estimate the runtime
of an algorithm.
CS-6202 : ALGORITHMS and COMPLEXITY
Module 1: Introduction
All these factors influence the actual runtime of an algorithm.To compare the runtime
behavior of algorithms is important to have a mean to eliminate all these factors and to find a
common description of the runtime.
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 space complexity.
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.
CS-6202 : ALGORITHMS and COMPLEXITY
Module 1: Introduction
For example, if we are analyzing a sorting algorithm we might count the number of
comparisons performed, and if it is an algorithm to find some optimal solution, the
number of times it evaluates a solution. If it is a graph coloring algorithm we might count
the number of times we check that a colored node is compatible with its neighbors.
A function of input. However, we will attempt to characterize this by the size of the input.
We will try and estimate the WORST CASE, and sometimes the BEST CASE, and very
rarely the AVERAGE CASE.
Worst Case ...the worst-case runtime complexity of the algorithm is the function defined
by the maximum number of steps taken on any instance of size a.
Best Case ... the best-case runtime complexity of the algorithm is the function defined by
the minimum number of steps taken on any instance of size a.
Average Case ...the average case runtime complexity of the algorithm is the function
defined by an average number of steps taken on any instance of size a.
CS-6202 : ALGORITHMS and COMPLEXITY
Module 1: Introduction
References:
1. https://www.tutorialspoint.com/Algorithms-and-Complexities?fbclid=IwAR
0F12_mkFt8hoQLfRkWjbVhKXEvdodMDrM5fE3_MrlSBuVRo4I1OXuHt4U
2. https://www.hackerearth.com/practice/notes/complexity/