time complexity of algorithm

 

Time complexity

Sort

 

time complexity of algorithm

Algorithm Sorts

Best case

Average case

Worst case

Bubble sort

O(n)

O(n2)

O(n2)

Insertion sort

O(n)

O(n2)

O(n2)

Selection sort

O(n2)

O(n2)

O(n2)

Merge sort

O(n*log n)

O(n*log n)

O(n*log n)

Quick sort

O(n log n)

O(n log n)

O(n2)

Binary search

O(1)

O(n log n)

O(n log n)

Liner search

O(1)

O(n)

O(n)

Count sort

O(n+k)

O(n+k)

O(n+k)


Time complexity:-

   is defined as the amount of time taken by an algorithm to run, as a function of the length of the input. It measures the time taken to execute each statement of code in an algorithm. It is not going to examine the total execution time of an algorithm.

1 Comments

Post a Comment
Previous Post Next Post