On the Best Case of Heapsort

Although discovered some 30 years ago, the Heapsort algorithm is still not completely understood. Here we investigate thebest caseof Heapsort. Contrary to claims made by some authors that its time complexity isO(n), i.e., linear in the number of items, we prove that it is actuallyO(nlogn) and is, in fact, approximately half that of the worst case. Our proof contains a construction for an asymptotically best-case heap. In addition, the proof and construction provide theworst-casetime complexity and an asymptotically worst-case example forBottom-upversions of Heapsort.