in Algorithms retagged by
15,493 views
4 votes
4 votes

Which of the following sorting algorithms does not have a worst case running time of $O(n​^2​)$?

  1. Insertion sort.
  2. Merge sort.
  3. Quick sort.
  4. Bubble sort.
in Algorithms retagged by
by
15.5k views

1 comment

Merge sort.
1
1

11 Answers

0 votes
0 votes

for every case Merge Sort give TC = O ( n logn ) 

and nlogn < n^2 , so merge sort takes less than n^2.

0 votes
0 votes
Worst case time of insertion sort is O(n^2) when array is in decreasing order like 9, 8 , 7 ,6

Worst case time of merge sort is O(n*logn) . Time complexity of merge sort is always n*logn whether it is worst case , best case or average case

Worst case time of bubble sort is O(n*n) when array is in decreasing order

Worst case  time of quick sort is O(n^2) . quick sort gives worst case time when it is in ascending order or descending order or when all elements of an array are same.
0 votes
0 votes
Merge sort- nlogn all cases
0 votes
0 votes
Merge sort.

You may think of quick sort also,but worst case time complexity of quick sort is O(n^2) in the case when the array is already sorted either in ascending or descending order.
Answer:

Related questions