Insertion sort better than Bubble sort?
algorithm, bubble-sort, insertion-sort, sorting
Solution
The advantage of bubblesort is in the speed of detecting an already sorted list:
BubbleSort Best Case Scenario: O(n)
However, even in this case insertion sort got better/same performance.
Bubblesort is, more or less, only good for understanding and/or teaching the mechanism of sortalgorithm, but wont find a proper usage in programming these days, because its complexity
O(n²)
means that its efficiency decreases dramatically on lists of more than a small number of elements.
Problem
I am doing my revision for the exam. Would like to know under what condition will Insertion sort performs better than bubble sort given same average case complexity of O(N^2). I did found some related articles, but I can't understand them. Would anyone mind explaining it in a simple way?