Definition Of The Time Complexity Of An Algorithm

959 Words2 Pages

Time Complexity
Definition:
“Time Complexity of an algorithm signifies the total time required by the program to run to completion.The Time complexity of algorithm is most commonly expressed using the big O notation”. “Time Complexity is most commonly estimated by counting the number of elementary functions performed by the algorithm.”
Big O Notation:
Big O notation is an upper bound, the worst-case time; Big O notation is required to run an algorithm on various inputs.
Example: if the time required by an algorithm on all inputs of size n is at most 5n3 + 3n.
Big Omega Notation:
Big Omega notation is a lower bound, the best-case time is proportional to the function multiplied by some constant factor.
Example: Quick sort …show more content…

Example: exchange the value of a and b if necessary so that a=<b^n is called constant time.
Linear Time:
An algorithm is said to be linear if its time complexity is O (n)
Function needs amount of time that is directly proportional to the number of input elements.
Example: Finding small values of n.

Quadratic Time: An algorithm is said to be quadratic if its time complexity is O (n^2)
Function needs amount of time that is quadratic proportional to the number of input elements.
Example: bubble sort algorithm, insertion sort algorithm, and selection sort algorithm.
Sub-Quadratic Time:
An algorithm is said to be Sub-quadratic time if T (n) =O (n^2)
Example: Shell Sort
Logarithmic time:
An algorithm is said to be Logarithmic time if T (n) =O (logn). When we performed operation on binary trees so we take logarithmic time.
Example: very easy example is that an algorithm that cuts a string in half.That is take O (logn) time (n is the length of the string)
Polylogarithmic time:
An algorithm is said to be Polylogarithmic time if T (n) = O ((logn) ^k)
Example: matrix chain

More about Definition Of The Time Complexity Of An Algorithm

Open Document