Time complexity
Time complexity is a Running time of a program as a function of the size of the input.
Space complexity
Space complexity analyzes the algorithms, based on how much space an algorithm needs to complete its task. Space complexity analysis was critical in the early days of computing (when storage space on the computer was limited).
Nowadays, the problem of space rarely occurs because space on the computer is broadly enough.
We achieve the following types of analysis for complexity
Worst-case: f(n)
It is defined by the maximum number of steps taken on any instance of size n.
Best-case: f(n)
It is defined by the minimum number of steps taken on any instance of size n.
Average-case: f(n)
It is defined by the average number of steps taken on any instance of size n.