MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following is an advantage of a insertion sort when compared with a bubble sort?
A
It is quicker than a bubble sort algorithm
B
It is simpler than a bubble sort algorithm
C
There is no advantage.
D
None of the above
Explanation: 

Detailed explanation-1: -Q. Which of the following is an advantage of a insertion sort when compared with a bubble sort? There is no advantage.

Detailed explanation-2: -On average, the bubble sort performs poorly compared to the insertion sort. Due to the high number of swaps, it’s expected to generate twice as many write operations and twice as many cache misses.

Detailed explanation-3: -Insertion sort has several advantages including: The pure simplicity of the algorithm. The relative order of items with equal keys does not change. The ability to sort a list as it is being received.

Detailed explanation-4: -Time Complexity of selection sort is always n(n-1)/2, whereas insertion sort has better time complexity as its worst case complexity is n(n-1)/2 . Generally it will take lesser or equal comparisons then n(n-1)/2 .

Detailed explanation-5: -Insertion sort is faster than some of the other O(n^2) sort algorithms because it has less overhead (especially when compared with bubble sort). There are also variations of sorting algorithms.

There is 1 question to complete.