Smooth Heaps and a Dual View of Self-Adjusting Data Structures

László Kozma, Thatchaphol Saranurak · SIAM Journal on Computing · 2018

We present a new connection between self-adjusting binary search trees (BSTs) and heaps, two fundamental, extensively studied, and practically relevant families of data structures [B. Allen and I. Munro, J. ACM, 25 (1978), pp. 526--535; D. D. Sleator and R. E. Tarjan, J. ACM, 32 (1985), pp. 652--686; M. L. Fredman et al., Algorithmica, 1 (1986), pp. 111--129; R. Wilber, SIAM J. Comput., 18 (1989), pp. 56--67; M. L. Fredman, in WAE 1999, Springer, Berlin, 1999, pp. 244--258; J. Iacono and Ö. Özkan, in ICALP 2014, Springer, Berlin, 2014, pp. 637--649]. Roughly speaking, we map an arbitrary heap algorithm within a natural model, to a corresponding BST algorithm with the same cost on a dual sequence of operations (i.e., the same sequence with the roles of time and key-space switched). This is the first general transformation between the two families of data structures. There is a rich theory of dynamic optimality for BSTs (i.e., the theory of competitiveness between BST algorithms). The lack of an analogous theory for heaps has been noted in the literature (e.g., [S. Pettie, in FOCS 2005, IEEE, Washington, DC, 2005, pp. 174--183; S. Pettie, in SODA 2008, ACM, New York, SIAM, Philadelphia, 2008, pp. 1115--1124]). Through our connection, we transfer all instance-specific lower bounds known for BSTs to a general model of heaps, initiating a theory of dynamic optimality for heaps. On the algorithmic side, we obtain a new, simple, and efficient heap algorithm, which we call the smooth heap. We show the smooth heap to be the heap-counterpart of Greedy, the BST algorithm with the strongest proven and conjectured properties from the literature, widely believed to be instance-optimal [J. M. Lucas, Canonical Forms for Competitive Binary Search Tree Algorithms, Tech. rep. DCS-TR-250, Rutgers University, New Brunswick, NJ, 1988; J. Munro, in Algorithms---ESA 2000, Lecture Notes in Comput. Sci. 1879, Springer, Berlin, Heidelberg, 2000, pp. 338--345; E. D. Demaine et al., in SODA 2009, AMC, New York, SIAM, Philadelphia, 2009, pp. 496--505]. Assuming the optimality of Greedy, the smooth heap is also optimal within our model of heap algorithms. As corollaries of results known for Greedy, we obtain instance-specific upper bounds for the smooth heap, with applications in adaptive sorting. Intriguingly, the smooth heap, although derived from a non-practical BST algorithm, is simple and easy to implement (e.g., it stores no auxiliary data besides the keys and tree pointers). It can be seen as a variation on the popular pairing heap data structure, extending it with a “power-of-two-choices” type of heuristic.

Read the paper · More papers on PaperTik