Optimal Incremental Sorting

Let A be a set of size m. Obtaining the first k ≤ m elements of A in ascending order can be done in optimal O(m+k log k) time. We present an algorithm (online on k) which incrementally gives the next smallest element of the set, so that the first k elements are obtained in optimal time for any k. We also give a practical version of the algorithm, with the same complexity on average, which performs better in practice than the best existing online algorithm. As a direct application, we use our technique to implement Kruskal's Minimum Spanning Tree algorithm, where our solution is competitive with the best current implementations. We finally show that our technique can be applied to several other problems, such as obtaining an interval of the sorted sequence and implementing heaps.

[1]  Manuel Blum,et al.  Time Bounds for Selection , 1973, J. Comput. Syst. Sci..

[2]  John M. Chambers,et al.  Algorithm 410: Partial sorting , 1971 .

[3]  Svante Janson,et al.  The Birth of the Giant Component , 1993, Random Struct. Algorithms.

[4]  Gaston H. Gonnet,et al.  Handbook Of Algorithms And Data Structures , 1984 .

[5]  Philip N. Klein,et al.  A randomized linear-time algorithm to find minimum spanning trees , 1995, JACM.

[6]  Robert E. Tarjan,et al.  The pairing heap: A new form of self-adjusting heap , 2005, Algorithmica.

[7]  R. Prim Shortest connection networks and some generalizations , 1957 .

[8]  G. H. Gonnet,et al.  Handbook of algorithms and data structures: in Pascal and C (2nd ed.) , 1991 .

[9]  Robert E. Tarjan,et al.  Fibonacci heaps and their uses in improved network optimization algorithms , 1984, JACM.

[10]  Mark Allen Weiss,et al.  Data structures & algorithm analysis in Java , 1999 .

[11]  Peter Sanders Fast Priority Queues for Cached Memory , 1999, ALENEX.

[12]  Conrado Martínez Partial Quicksort , 2003 .

[13]  R. K. Shyamasundar,et al.  Introduction to algorithms , 1996 .

[14]  Henry D. Shapiro,et al.  for An empirical analysis of algorithms , 2005 .

[15]  C. A. R. Hoare,et al.  Algorithm 65: find , 1961, Commun. ACM.

[16]  Robert E. Tarjan,et al.  Data structures and network algorithms , 1983, CBMS-NSF regional conference series in applied mathematics.

[17]  Ingo Wegener BOTTOM-UP-HEAPSORT, a New Variant of HEAPSORT, Beating, on an Average, QUICKSORT (if n is not Very Small) , 1993, Theor. Comput. Sci..

[18]  J. Kruskal On the shortest spanning subtree of a graph and the traveling salesman problem , 1956 .

[19]  Bernard Chazelle,et al.  A minimum spanning tree algorithm with inverse-Ackermann type complexity , 2000, JACM.

[20]  Jesper Larsson Träff,et al.  A Practical Minimum Spanning Tree Algorithm Using the Cycle Property , 2003, ESA.

[21]  Seth Pettie,et al.  An optimal minimum spanning tree algorithm , 2000, JACM.