The complexity measure the quantity of resources used by an algorithms as a function of the problem size. One is especially interested in the trend of the complexity when the problem size becomes large, tends towards infinity.
Time Complexity –
How to choose an algorithm and/or a data
structure representation?
1. Effort for implementing the algorithm:
1.1. searching the literature
1.2. programming
1.3. testing
1.4. maintenance
2. Resources used for running the algorithm:
2.1. time (of computation)
2.2. space (in memory)
2.3. energy (number of processors)
Time complexity means to time taken to execute an algorithm. An algorithm should be much time efficient. Time complexity is calculated by counting the no. of elementry functions. Usually take the possibility as worst case.
Calculation of time complexity is done in 4 notations : :-
1- O Notation : In this we take every possible condition which slows our program, “the worst case” is notifies by Big O Notation.
2- Omega Notation : Function that grows atleast as fast from expression.
3- Theta Notation : Consist of all function lies in both O and Omega.
eg :
f(n) = 3*n^2 + 4*n + 5
The worst case here is defined by theta(n^2) . Same as it can be defined as O(n^2) and Omega(n^2).
Space Complexity : An amount of memory is required at the time of execution for every program. We have to define a memory efficient algo for use at multiple systems.
Every programs divide its space in three parts:
1: Instruction Space : The space required to store the program in Memory. This space is fixed and depends upon number of line of code, iterators and algos.
2: Data Space : It is the space required to store all the variables and data defined in programs, which can be stored in memory or RAM as well.
3: Environment Space : Its the space required to store the program needed to resume function.