<p>The $\Omega(n^2)$ worst-case lower bound of Comb sort (or Dobosiewicz sort) has also been proved using the incompressibility method based on Kolmogorov complexity. See for example the <a href="http://homepages.cwi.nl/~paulv/papers/sorting.pdf">survey</a> by Vitanyi, page 16. If you are also interested in the average-case lower bound on the running time, the paper gives that as well. Moreover the proofs obtained with the method are natural, easy-to-follow and usually quite short.</p>

CC BY-SA 3.0
2012-01-05T23:59:52.607Z
2012-01-05T23:59:52.607Z
Juho
<p>So after some digging it looks like the original analysis in Wikipedia was incorrect.  <a href="http://www.sciencedirect.com/science/article/pii/S0020019000002234" rel="nofollow">This paper</a> cites an older paper that gives $\Omega(n^2)$ as a lower bound for comb sort, and actually says that it was still an open problem (as of the time that the paper was written) to determine whether the worst-case actually was $O(n^2)$ on all inputs.  I've updated the Wikipedia article appropriately.</p>

CC BY-SA 3.0
2012-01-05T23:30:17.830Z
2012-01-05T23:30:17.830Z
templatetypedef
<blockquote>
  <p><strong>EDIT:</strong> The Wikipedia article mentioned here was incorrect and has since been updated.  Comb sort's worst-case behavior is $\Omega(n^2)$, not $O(n \log n)$ as was claimed.</p>
</blockquote>

<p>Yesterday I stumbled on the comb sort algorithm, a modification of bubble sort similar in spirit to Shell sort.  The idea is to maintain a gap of some size, then use a bubble-sort pass over the array using that gap size to roughly position the elements into their proper positions.  Each iteration decreases the gap size, until eventually the algorithm degrades into bubble sort.</p>

<p><a href="http://en.wikipedia.org/wiki/Comb_sort" rel="noreferrer">The Wikipedia article</a> claims that the algorithm runs in O(n log n) time worst-case, but the citation for this claim is <a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CB8QFjAA&amp;url=http%3A%2F%2Fwww.lix.polytechnique.fr%2F~nielsen%2Fpdf%2F2009-KnnGPU-MIRAGE.pdf&amp;rct=j&amp;q=searching%20high%20dimensional%20neighbours%20cpu&amp;ei=qCQGT7jMFKiViALkpORE&amp;usg=AFQjCNFk_Zlwm0t7YZbX42406ZOlnkAIBA" rel="noreferrer">a paper on GPU processing</a> that mentions this result offhand without providing any analysis or citation.  One of the original papers on comb sort doesn't even attempt to prove a worst-case bound, and in fact not a single source I've found has attempted to analyze the worst-case or even average-case complexity of comb sort.  This concerns me, since I've found a lot of sites that are clearly getting their information from the Wikipedia article, and I would hate for a single bad source to propagate the O(n log n) claim if it is incorrect.</p>

<p>My question is this: <strong>is there a reliable source that proves the O(n log n) worst-case behavior of comb sort?</strong></p>

<p>Thanks!</p>

CC BY-SA 3.0
2012-01-05T22:32:34.903Z
If you pretend the gap reduces by a factor of 2 at each step, then after the first step when gap <= 2, then we are left with two sequences (odd and even) that are individually sorted. Clearly, it takes only linear time at this stage to merge them, and the time to get here is $O(n\log n)$ since each step takes at most $n$ time, and the gap starts at $n$, reducing by a constant factor at each step.
Suresh Venkat
CC BY-SA 3.0
2012-01-05T22:38:23.800Z
@SureshVenkat- Comb sort doesn't work by repeatedly applying bubble sort until the elements spaced by the gap are sorted; instead it applies one pass swapping elements spaced by the gap that are out of order and then decreases the gap.  As a result, I don't think you can claim that after the 2-gap pass you have two interleaved sorted sequences.  Let me know if I'm wrong about this.
templatetypedef
<ds.algorithms><reference-request>
Analysis of Comb Sort?
templatetypedef
# Analysis of Comb Sort?

(Asked by: username_0 on 2012-01-05)

> **EDIT:** The Wikipedia article mentioned here was incorrect and has since been updated. Comb sort's worst-case behavior is $\Omega(n^2)$, not $O(n \log n)$ as was claimed.

Yesterday I stumbled on the comb sort algorithm, a modification of bubble sort similar in spirit to Shell sort. The idea is to maintain a gap of some size, then use a bubble-sort pass over the array using that gap size to roughly position the elements into their proper positions. Each iteration decreases the gap size, until eventually the algorithm degrades into bubble sort.

[The Wikipedia article](http://en.wikipedia.org/wiki/Comb_sort) claims that the algorithm runs in O(n log n) time worst-case, but the citation for this claim is [a paper on GPU processing](http://www.google.com/url?sa=t&source=web&cd=1&ved=0CB8QFjAA&url=http%3A%2F%2Fwww.lix.polytechnique.fr%2F~nielsen%2Fpdf%2F2009-KnnGPU-MIRAGE.pdf&rct=j&q=searching%20high%20dimensional%20neighbours%20cpu&ei=qCQGT7jMFKiViALkpORE&usg=AFQjCNFk_Zlwm0t7YZbX42406ZOlnkAIBA) that mentions this result offhand without providing any analysis or citation. One of the original papers on comb sort doesn't even attempt to prove a worst-case bound, and in fact not a single source I've found has attempted to analyze the worst-case or even average-case complexity of comb sort. This concerns me, since I've found a lot of sites that are clearly getting their information from the Wikipedia article, and I would hate for a single bad source to propagate the O(n log n) claim if it is incorrect.

My question is this: **is there a reliable source that proves the O(n log n) worst-case behavior of comb sort?**

Thanks!

**Tags:** ds.algorithms, reference-request
> **Comments:**
> **username_1**: If you pretend the gap reduces by a factor of 2 at each step, then after the first step when gap <= 2, then we are left with two sequences (odd and even) that are individually sorted. Clearly, it takes only linear time at this stage to merge them, and the time to get here is $O(n\log n)$ since each step takes at most $n$ time, and the gap starts at $n$, reducing by a constant factor at each step.  
> **username_0**: @SureshVenkat- Comb sort doesn't work by repeatedly applying bubble sort until the elements spaced by the gap are sorted; instead it applies one pass swapping elements spaced by the gap that are out of order and then decreases the gap.  As a result, I don't think you can claim that after the 2-gap pass you have two interleaved sorted sequences.  Let me know if I'm wrong about this.  

---

## 2 answers

### Answer by username_2 on 2012-01-05. Score: 5 | Accepted answer

The $\Omega(n^2)$ worst-case lower bound of Comb sort (or Dobosiewicz sort) has also been proved using the incompressibility method based on Kolmogorov complexity. See for example the [survey](http://homepages.cwi.nl/~paulv/papers/sorting.pdf) by Vitanyi, page 16. If you are also interested in the average-case lower bound on the running time, the paper gives that as well. Moreover the proofs obtained with the method are natural, easy-to-follow and usually quite short.


---

### Answer by username_0 on 2012-01-05. Score: 3

So after some digging it looks like the original analysis in Wikipedia was incorrect. [This paper](http://www.sciencedirect.com/science/article/pii/S0020019000002234) cites an older paper that gives $\Omega(n^2)$ as a lower bound for comb sort, and actually says that it was still an open problem (as of the time that the paper was written) to determine whether the worst-case actually was $O(n^2)$ on all inputs. I've updated the Wikipedia article appropriately.


---

