1,472 views
1 votes
1 votes
Consider following Statements :

S1 : On any random input insertion Sort works more efficiently then Bubble Sort.

S2 : Average number of Comparison of Insertion Sort is better then bubble sort by a constant Factor.

If efficiency is considered as number of comparisons to sort an Input Array Which of Following is Correct ?

A. Only S1

B. Only S2

C. Both S1 and S2

D. None

1 Answer

0 votes
0 votes
It should be B I guess, as A is not true when both the arrays are in descending order. Insertion sort will take the same amount of comparisons as bubble sort.

But on an average, bubble sort is much less efficient than insertion sort due to the fact that insertion only compares till its found the right position, while bubble sort has to go till the end of the array.

Related questions

1 votes
1 votes
0 answers
1
1 votes
1 votes
0 answers
2
vineet.ildm asked Jul 18, 2017
1,002 views
will A[i+1]=key; in the insertion sort be counted as a movement in best case?
4 votes
4 votes
1 answer
3
sh!va asked Apr 27, 2017
1,766 views
Selection sort is an example of ____(I)_______ and insertion sort is an example of __(II)______.a) I- Greedy, II- Brute Forceb) I- Brute Force II- Divide and conquerc) I-...