retagged by
290 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

773
views
1 answers
0 votes
tusharb asked Feb 18, 2022
773 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 reduce the time complexity to O(n)?
556
views
1 answers
0 votes
eyeamgj asked Aug 25, 2018
556 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 they both same ??and what is the tym complexity to delete an element?
1.2k
views
3 answers
0 votes
aditi19 asked Oct 6, 2018
1,184 views
what is the recurrence relation for merge sort?
863
views
1 answers
0 votes
LavTheRawkstar asked Jan 12, 2017
863 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[i+1] ← A[i]; i ← i – 1; }A[i+1] = key;