retagged by
6,482 views
6 votes
6 votes
options

A. insertion

B. quick

C. selection

D. merge
retagged by

2 Answers

Best answer
10 votes
10 votes

ans D

insertion sort : if the initial ordering is in reverse order it takes O(n2).

quick sort :if the initial ordering is in reverse order or sorted  it takes O(n2)

selection sort : best case and worst case O(n2 ) it does not depend upon the order but swaping takes less (if sorted ) 

merge sort : in all cases O(nlogn) and its the ans ( i guess) 

selected by
2 votes
2 votes
option C,D

insertion sort: you must have played cards .its better to sort a hand rank wise if its not sorted .if its sorted already then no need to  sort it

quick sort:here the pivot element plays an important role.if the array is sorted and your algorithm  chooses the first element as pivot then you are going to get a worse case scenario

selection  sort:if its already sorted or not sorted it doesn't matter it always takes O(n^2)

merge sort:it too takes O(nlogn) time in any case

Related questions

8 votes
8 votes
2 answers
1
3 votes
3 votes
1 answer
4
Sanjay Sharma asked Feb 20, 2018
1,099 views
An array A is of length n has log( n) distinct numbers.What is the time complexity of sorting A by best comparison based algorithm ?