in reply to Advanced Bubble Sort
It seems to me that most everyone in this thread has completely misunderstood your title: the required "bubble sort" is "advanced" because it only requires a single, linear pass.
Thus O(n) rather than O(n+nlogn); or O(nlogn+nlogn); or O(nlogn)(with a very large constant); or O(MG).
Essentially you were describing a "find the biggest in each subgroup" algorithm; which doesn't involve any actual sorting whatsoever; and doesn't require every line to be compared to every other line, only with those lines with the same prefix; and only once each.
Of course, for the size of the sample data the difference is miniscule; but ...
|
|---|