Time Complexity Sorintg

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 4

Time Complexity of Sorting

Algorithms
Insertion Sort
Best Case : When the elements are already
sorted O(n)

Worst case: When the elements are sorted in


the reverse order O(n2)
Merger Sort

Time complexity is O(nlogn)


Quick Sort

Worst case when every time the array splits


subarrays of 0 and N-1 elemetns. O(n2)

Best case when partioning happes at n/2


every time. O(nlogn).

You might also like