## The Ultimate Heapsort (1998)

Venue: | In Proceedings of the Computing: the 4th Australasian Theory Symposium, Australian Computer Science Communications |

Citations: | 4 - 0 self |

### BibTeX

@TECHREPORT{Katajainen98theultimate,

author = {Jyrki Katajainen},

title = {The Ultimate Heapsort},

institution = {In Proceedings of the Computing: the 4th Australasian Theory Symposium, Australian Computer Science Communications},

year = {1998}

}

### Years of Citing Articles

### OpenURL

### Abstract

. A variant of Heapsort---named Ultimate Heapsort---is presented that sorts n elements in-place in \Theta(n log 2 (n+ 1)) worst-case time by performing at most n log 2 n + \Theta(n) key comparisons and n log 2 n + \Theta(n) element moves. The secret behind Ultimate Heapsort is that it occasionally transforms the heap it operates with to a two-layer heap which keeps small elements at the leaves. Basically, Ultimate Heapsort is like Bottom-Up Heapsort but, due to the two-layer heap property, an element taken from a leaf has to be moved towards the root only O(1) levels, on an average. Let a[1::n] be an array of n elements each consisting of a key and some information associated with this key. This array is a (maximum) heap if, for all i 2 f2; : : : ; ng, the key of element a[bi=2c] is larger than or equal to that of element a[i]. That is, a heap is a pointer-free representation of a left complete binary tree, where the elements stored are partially ordered according to their keys. Ele...

### Citations

148 |
ACM algorithm 232: Heap sort
- Williams
- 1964
(Show Context)
Citation Context ...of a[i+1], for all i 2 f1; 2; : : : ; n \Gamma 1g. 1. Rearrange a[1::n] into a heap. 2. for i / n step -1 until 2 do Exchange a[1] and a[i]. Remake a[1::i \Gamma 1] into a heap. According to Williams =-=[29]-=-, who invented Heapsort and the heap data structure, Heapsort is a marriage of Treesort developed by Floyd [11] and Tournamentsort described, for instance, by Iverson [16, Section 6.4] (see also [13])... |

26 |
a new variant of heapsort beating, on an average, quicksort (if n is not very small
- Bottom-up-heapsort
- 1993
(Show Context)
Citation Context ...easily reduced to, say 1:625n. As to Heapsort, the number of key comparisons performed has been gradually reduced to 3 log 2 3 n log 2 n + \Theta(n) [21, Exercise 5.2.3-28], 3 2 n log 2 n + \Theta(n) =-=[1, 10, 24, 26]-=-, 4 3 n log 2 n + \Theta(n) [30, 31], 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) [3, 14]. Here log 2 n is defined as 1 + log... |

23 |
Heaps on heaps
- Gonnet, Munro
- 1986
(Show Context)
Citation Context ..., 3 2 n log 2 n + \Theta(n) [1, 10, 24, 26], 4 3 n log 2 n + \Theta(n) [30, 31], 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) =-=[3, 14]-=-. Here log 2 n is defined as 1 + log 2 (log 2 n), if n ? 2, and otherwise it is 1. It is even possible to reduce the number of key comparisons to n log 2 n + \Theta(n)---without increasing the running... |

19 | Dijkstra: A discipline of programming - W - 1976 |

17 |
The analysis of heapsort
- Schaffer, Sedgewick
- 1993
(Show Context)
Citation Context ...ation. In the form programmed by Williams [29], Heapsort sorts an array of size n in \Theta(n log 2 (n + 1)) time by performing about 3n log 2 n key comparisons and 4 3 4 n log 2 n element moves (cf. =-=[24]-=-) in the worst case. Soon after the publication of Heapsort, Floyd [12] improved it by showing that (1) the construction of a heap for n elements can be accomplished in-place in \Theta(n) time by perf... |

15 |
variant of HEAPSORT with almost optimal number of comparisons
- Carlsson
(Show Context)
Citation Context ...oyd [12] improved it by showing that (1) the construction of a heap for n elements can be accomplished in-place in \Theta(n) time by performing fewer than 2n key comparisons and 2n element moves, and =-=(2)-=- n elements can be sorted in-place in \Theta(n log 2 (n + 1)) time by performing at most 2n log 2 n + \Theta(n) key comparisons and n log 2 n + \Theta(n) element moves. Floyd's results have been impro... |

13 | Knuth: The Art of Computer Programming, Volume 3: Sorting and Searching - E - 1997 |

12 |
Implicit selection
- Lai, Wood
- 1988
(Show Context)
Citation Context ...as the 2 d th largest key of the elements in a[1::n], where 2 d is the largest power of 2 smaller than or equal to n. This can be done, e.g., by using the in-place selection algorithm of Lai and Wood =-=[22]-=-. 2. Partition a[1::n] into three pieces a[1::`], a[` + 1::` + e], and a[` + e + 1::n] such that the key of every element in a[1::`], a[` +1::`+e], and a[` +e+1::n] is larger than, equal to, and small... |

10 | In-place sorting with fewer moves
- Katajainen, Pasanen
- 1999
(Show Context)
Citation Context ...would like to point out that the performance of in-place Mergesort developed by Katajainen et al. [18] has been recently improved such that it will beat all known variants of Heapsort, both in theory =-=[17]-=- and in practice [20]. Postscript. The seminal idea of this paper has been exploited and the results have been improved in [19, 23]. Acknowledgements. The author would like to thank Volker Diekert, To... |

10 | Practical in-place Mergesort
- Katajainen, Pasanen, et al.
- 1996
(Show Context)
Citation Context ...ementation of Ultimate Heapsort does not compete well with Bottom-Up Heapsort in practice. Finally, I would like to point out that the performance of in-place Mergesort developed by Katajainen et al. =-=[18]-=- has been recently improved such that it will beat all known variants of Heapsort, both in theory [17] and in practice [20]. Postscript. The seminal idea of this paper has been exploited and the resul... |

8 |
A note on Heapsort
- Carlsson
- 1992
(Show Context)
Citation Context ..., 3 2 n log 2 n + \Theta(n) [1, 10, 24, 26], 4 3 n log 2 n + \Theta(n) [30, 31], 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) =-=[3, 14]-=-. Here log 2 n is defined as 1 + log 2 (log 2 n), if n ? 2, and otherwise it is 1. It is even possible to reduce the number of key comparisons to n log 2 n + \Theta(n)---without increasing the running... |

7 |
The worst case complexity of McDiarmid and Reed's variant of BOTTOM-UP HEAPSORT is less than n log n + 1:1n
- Wegener
- 1992
(Show Context)
Citation Context ...1. It is even possible to reduce the number of key comparisons to n log 2 n + \Theta(n)---without increasing the running time or the number of element moves---if extra storage for n bits is available =-=[5, 9, 25]-=- or if this behaviour is only called for in the average case [24, 26]. In this paper a new variant of Heapsort---named Ultimate Heapsort---is presented that guarantees \Theta(n log 2 (n + 1)) worst-ca... |

6 | A meticulous analysis of mergesort programs
- Katajainen, TrÃ¤ff
- 1997
(Show Context)
Citation Context ...ut that the performance of in-place Mergesort developed by Katajainen et al. [18] has been recently improved such that it will beat all known variants of Heapsort, both in theory [17] and in practice =-=[20]-=-. Postscript. The seminal idea of this paper has been exploited and the results have been improved in [19, 23]. Acknowledgements. The author would like to thank Volker Diekert, Tomi Pasanen, Laurent R... |

5 | Linear-time In-place Selection in Less than 3n Comparisons - Carlsson, Sundstrom |

4 |
A tight lower bound for the worst case of Bottom-Up-Heapsort
- Fleischer
- 1991
(Show Context)
Citation Context ...easily reduced to, say 1:625n. As to Heapsort, the number of key comparisons performed has been gradually reduced to 3 log 2 3 n log 2 n + \Theta(n) [21, Exercise 5.2.3-28], 3 2 n log 2 n + \Theta(n) =-=[1, 10, 24, 26]-=-, 4 3 n log 2 n + \Theta(n) [30, 31], 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) [3, 14]. Here log 2 n is defined as 1 + log... |

3 | Iverson: A Programming Language - E - 1962 |

2 |
Heap construction: Optimal in both worst and average cases
- Carlsson, Chen
- 1995
(Show Context)
Citation Context ...e been improved further. Now there exists an in-place algorithm that constructs a heap of size n in linear time by performing only 1:6316n + O(log 2 n) key comparisons in the worst case [7] (see also =-=[4]-=-). Moreover, the number of element moves can be easily reduced to, say 1:625n. As to Heapsort, the number of key comparisons performed has been gradually reduced to 3 log 2 3 n log 2 n + \Theta(n) [21... |

2 |
Optimal heapsort algorithm. Theoretical Computer Science 163
- Gu, Zhu
- 1996
(Show Context)
Citation Context ...3 n log 2 n + \Theta(n) [21, Exercise 5.2.3-28], 3 2 n log 2 n + \Theta(n) [1, 10, 24, 26], 4 3 n log 2 n + \Theta(n) [30, 31], 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) =-=[2, 15]-=-, and n log 2 n + n log 2 n + \Theta(n) [3, 14]. Here log 2 n is defined as 1 + log 2 (log 2 n), if n ? 2, and otherwise it is 1. It is even possible to reduce the number of key comparisons to n log 2... |

2 |
A simple modification of Xunrang and Yuzhang's HEAPSORT variant improving its complexity significantly
- Wegener
- 1993
(Show Context)
Citation Context ...rformed has been gradually reduced to 3 log 2 3 n log 2 n + \Theta(n) [21, Exercise 5.2.3-28], 3 2 n log 2 n + \Theta(n) [1, 10, 24, 26], 4 3 n log 2 n + \Theta(n) [30, 31], 7 6 n log 2 n + \Theta(n) =-=[27]-=-, n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) [3, 14]. Here log 2 n is defined as 1 + log 2 (log 2 n), if n ? 2, and otherwise it is 1. It is even possible t... |

1 |
Frieze: On the best case of Heapsort
- Bollob'as, Fenner, et al.
- 1996
(Show Context)
Citation Context ...an or equal to that of element a[i]. That is, a heap is a pointer-free representation of a left complete binary tree, where the elements stored are partially ordered according to their keys. Element a=-=[1]-=- with the largest key is stored at the root. Elements a[bi=2c], a[2i] and a[2i + 1] (if they exist) are respectively stored at the parent, the left child and the right child of the node at which eleme... |

1 |
Heaps with bits. Theoretical Computer Science 164
- Carlsson, Chen, et al.
- 1996
(Show Context)
Citation Context ...1. It is even possible to reduce the number of key comparisons to n log 2 n + \Theta(n)---without increasing the running time or the number of element moves---if extra storage for n bits is available =-=[5, 9, 25]-=- or if this behaviour is only called for in the average case [24, 26]. In this paper a new variant of Heapsort---named Ultimate Heapsort---is presented that guarantees \Theta(n log 2 (n + 1)) worst-ca... |

1 |
A framework for constructing heap-like structures in-place
- Chen
- 1993
(Show Context)
Citation Context ...'s results have been improved further. Now there exists an in-place algorithm that constructs a heap of size n in linear time by performing only 1:6316n + O(log 2 n) key comparisons in the worst case =-=[7]-=- (see also [4]). Moreover, the number of element moves can be easily reduced to, say 1:625n. As to Heapsort, the number of key comparisons performed has been gradually reduced to 3 log 2 3 n log 2 n +... |

1 |
Dutton: Weak-heap sort
- D
- 1993
(Show Context)
Citation Context ...1. It is even possible to reduce the number of key comparisons to n log 2 n + \Theta(n)---without increasing the running time or the number of element moves---if extra storage for n bits is available =-=[5, 9, 25]-=- or if this behaviour is only called for in the average case [24, 26]. In this paper a new variant of Heapsort---named Ultimate Heapsort---is presented that guarantees \Theta(n log 2 (n + 1)) worst-ca... |

1 |
Floyd: Algorithm 113: TREESORT
- W
- 1962
(Show Context)
Citation Context ... 2 do Exchange a[1] and a[i]. Remake a[1::i \Gamma 1] into a heap. According to Williams [29], who invented Heapsort and the heap data structure, Heapsort is a marriage of Treesort developed by Floyd =-=[11]-=- and Tournamentsort described, for instance, by Iverson [16, Section 6.4] (see also [13]). Both Treesort and Tournament-sort run in \Theta(n log 2 (n+1)) worst-case time and carry out n log 2 n + \The... |

1 |
Floyd: Algorithm 245: TREESORT 3
- W
- 1964
(Show Context)
Citation Context ... of size n in \Theta(n log 2 (n + 1)) time by performing about 3n log 2 n key comparisons and 4 3 4 n log 2 n element moves (cf. [24]) in the worst case. Soon after the publication of Heapsort, Floyd =-=[12]-=- improved it by showing that (1) the construction of a heap for n elements can be accomplished in-place in \Theta(n) time by performing fewer than 2n key comparisons and 2n element moves, and (2) n el... |

1 |
Friend: Sorting on electronic computer systems
- H
- 1956
(Show Context)
Citation Context ... [29], who invented Heapsort and the heap data structure, Heapsort is a marriage of Treesort developed by Floyd [11] and Tournamentsort described, for instance, by Iverson [16, Section 6.4] (see also =-=[13]-=-). Both Treesort and Tournament-sort run in \Theta(n log 2 (n+1)) worst-case time and carry out n log 2 n + \Theta(n) key comparisons and n log 2 n + \Theta(n) element moves. For example, Treesort use... |

1 |
Top-Down Not-Up Heapsort
- Katajainen, Pasanen, et al.
- 1997
(Show Context)
Citation Context ...ed such that it will beat all known variants of Heapsort, both in theory [17] and in practice [20]. Postscript. The seminal idea of this paper has been exploited and the results have been improved in =-=[19, 23]-=-. Acknowledgements. The author would like to thank Volker Diekert, Tomi Pasanen, Laurent Rosaz, and Jukka Teuhola for interesting discussions concerning the subject of this paper. This work was partia... |

1 |
Improving Katajainen's Ultimate Heapsort. Proceedings of the Algorithm Day in Copenhagen
- Rosaz
- 1997
(Show Context)
Citation Context ...ed such that it will beat all known variants of Heapsort, both in theory [17] and in practice [20]. Postscript. The seminal idea of this paper has been exploited and the results have been improved in =-=[19, 23]-=-. Acknowledgements. The author would like to thank Volker Diekert, Tomi Pasanen, Laurent Rosaz, and Jukka Teuhola for interesting discussions concerning the subject of this paper. This work was partia... |

1 |
Wegner: Quicksort for equal keys
- M
- 1985
(Show Context)
Citation Context ...[1::`], a[` +1::`+e], and a[` +e+1::n] is larger than, equal to, and smaller than that of x, respectively. Here the 3-way partitioning algorithm described, e.g., by Dijkstra [8, Chapter 14] or Wegner =-=[28]-=- could be used. 3. Rearrange a[1::`] into a heap, e.g., by using the standard heap-construction algorithm [12]. Lemma 1. A two-layer heap for n elements can be constructed in-place in \Theta(n) time b... |

1 |
Yuzhang: A new HEAPSORT algorithm and the analysis of its complexity
- Xunrang, Z
- 1990
(Show Context)
Citation Context ...rt, the number of key comparisons performed has been gradually reduced to 3 log 2 3 n log 2 n + \Theta(n) [21, Exercise 5.2.3-28], 3 2 n log 2 n + \Theta(n) [1, 10, 24, 26], 4 3 n log 2 n + \Theta(n) =-=[30, 31]-=-, 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) [3, 14]. Here log 2 n is defined as 1 + log 2 (log 2 n), if n ? 2, and otherwis... |

1 |
Asymptotic optimal HEAPSORT algorithm. Theoretical Computer Science 134
- Xunrang, Yuzhang
- 1994
(Show Context)
Citation Context ...rt, the number of key comparisons performed has been gradually reduced to 3 log 2 3 n log 2 n + \Theta(n) [21, Exercise 5.2.3-28], 3 2 n log 2 n + \Theta(n) [1, 10, 24, 26], 4 3 n log 2 n + \Theta(n) =-=[30, 31]-=-, 7 6 n log 2 n + \Theta(n) [27], n log 2 n + n log 2 log 2 n + \Theta(n) [2, 15], and n log 2 n + n log 2 n + \Theta(n) [3, 14]. Here log 2 n is defined as 1 + log 2 (log 2 n), if n ? 2, and otherwis... |