retagged by
256 views

2 Answers

1 votes
1 votes
Sorting algo Worst case Occurs  Best case occurs

Selection sort, 

insertion sort,

Bubble sort

When given elements are already sorted in reverse order of your desired sorting, eg: you want to sort in ascending But given elements are in already descending  When given elements are already sorted in your desired sorting order.
Quick sort When elements are sorted in either ascending or descending or all elements are equal all other then given worst case is best case
merge sort

 The worst case of merge sort will be the one where merge sort will have to do maximum number of comparisons.

https://stackoverflow.com/questions/24594112/when-will-the-worst-case-of-merge-sort-occur

other then worst is best case
Counting Sort not in GATE syllabus not in GATE syllabus
 Bucket Sort not in GATE syllabus not in GATE syllabus

 

0 votes
0 votes
SS and IS :: $ 54321 $

MS ::: it takes same time for best and worst (whatever input it is) $ O(n logn) $

QS :: Inputs are in ascending order or descending order or All elements are same.

BS ::  It performs at  $O(n^2)$ when all elements at allocated to the same bucket.

CS :: When range is too high. EX - $[1,1000,2,6]$

BS :: Sorted in reverse order. $[5,4,3,2,1]$

Related questions

0 votes
0 votes
1 answer
1
tusharb asked Feb 18, 2022
695 views
As we know the time complexity of solving the greedy knapsack algorithm depends mainly on the sorting algorithm used, Can we use counting sort as the sorting algorithm to...
0 votes
0 votes
1 answer
2
eyeamgj asked Aug 25, 2018
487 views
suppose we are given a sorted array ....and we need to extract minimum every tym what is the time complexity??and what is the tym complexity to delete the minimum ? are ...
0 votes
0 votes
3 answers
3
aditi19 asked Oct 6, 2018
1,143 views
what is the recurrence relation for merge sort?
0 votes
0 votes
1 answer
4
LavTheRawkstar asked Jan 12, 2017
833 views
INSERTION-SORT (A, n) ⊳ A[1 . . n]for (j ← 2 to len(A) ){key ← A[ j];i ← j – 1 ; while (i 0 and A[i] key) { A[...