retagged by
3,731 views
0 votes
0 votes
.You want to check whether a given set of items is sorted or not.Which of the following sorting methods will be the most efficient if it is already in sorted order?
a. Bubble sort b. Selection sort c. Insertion sort   d.Merge sort
retagged by

1 Answer

3 votes
3 votes
  • The standard Bubble sort implementation takes $O\left ( n^{2} \right )$ time in any case (though we have a modified version of it which can detect if there were any swaps made), but here we can't assume that the mentioned Bubble Sort procedure is modified.
  • The Selection sort procedure is also going to take $O\left ( n^{2} \right )$ time.
  • Merge Sort runs in $\Theta \left ( nlogn \right )$ time.
  • The best algorithm to detect a sorted sequence is Insertion Sort. In case of sorted input, this procedure will terminate in $O\left ( n \right )$ time.

Hence option C is correct.

Related questions

2 votes
2 votes
1 answer
2
yes asked Oct 6, 2015
1,384 views
for example array contain a[1 2 3 3 3 3 3 4 5] then retun(1)
2 votes
2 votes
1 answer
3
Kapil asked Sep 29, 2016
965 views
Check whether the given schedule is conflict serializable or not ? R2(A); R3(C); W3(A); W2(A); W2(B); W3(C); R1(A); R1(B); W1(A); W1(B)
0 votes
0 votes
1 answer
4