TIME COMPLEXITY:Time compexity is(roughly speaking) how the algorithm behaves as the input increases. Something with time complexity O(n) will take twice the time when the input doubles, something with time complexity O(N^2) will take four times longer when the input duobles and so on.

SPACE COMPLEXITY:Space complexity is the storage required for the execution of the algorithm. This includes all permanent and temporary storage required by the algoritm, including any necessary stakc allocations for recursions.

Time complexity is a function which describes the amount of time an algorithm takes in terms of the amount of input to the algorithm.

Space complexity is a function which describes the amount of memory (space) an algorithm takes in terms of the amount of input to the algorithm.

EXAMPLE:

The complexity of linear search algorithm for avarage case

c(n)=1*1/n+2*1/n+3*1/n+.........+n*1/n

=(n+1)/2