HackerPapers

arXiv:1806.06726cs.DS

Zip Trees

Robert E. Tarjan, Caleb C. Levy, Stephen Timmel

Abstract

We introduce the zip tree, a form of randomized binary search tree that integrates previous ideas into one practical, performant, and pleasant-to-implement package. A zip tree is a binary search tree in which each node has a numeric rank and the tree is (max)-heap-ordered with respect to ranks, with rank ties broken in favor of smaller keys. Zip trees are essentially treaps (Seidel and Aragon 1996), except that ranks are drawn from a geometric distribution instead of a uniform distribution, and we allow rank ties. These changes enable us to use fewer random bits per node. We perform insertions and deletions by unmerging and merging paths ("unzipping" and "zipping") rather than by doing rotations, which avoids some pointer changes and improves efficiency. The methods of zipping and unzipping take inspiration from previous top-down approaches to insertion and deletion (Stephenson 1980; Martínez and Roura 1998; Sprugnoli 1980). From a theoretical standpoint, this work provides two main results. First, zip trees require only $O(\log \log n)$ bits (with high probability) to represent the largest rank in an $n$-node binary search tree; previous data structures require $O(\log n)$ bits for the largest rank. Second, zip trees are naturally isomorphic to skip lists (Pugh 1990), and simplify the mapping of (Dean and Jones 2007) between skip lists and binary search trees.

arXiv comments
V5 is the final published version. V4 appeared in the Workshop on Algorithms and Data Structures in 2019. V1 was presented at Highlights of Algorithms in 2018. 14 pages, 3 figures
Journal reference
ACM Transactions on Algorithms, 17(4), 34:1--12, 2021
DOI
doi:10.1145/3476830
Subjects
cs.DSData Structures and Algorithms

On Hacker News

Linked by 4 identifiable commenters in 6 comments across 6 threads, from Oct 2018 to Apr 2026. Found in 1 HN submission from Oct 2018 to Oct 2018. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments6 threads

  1. What are skiplists good for? 1 comment
    • Maestro Tarjan tells us skiplists and treaps are very nearly the same thing: https://arxiv.org/abs/1806.06726. I don’t see how to transpose TFA’s extension of the former to the latter, though.

      mananaysiempreView on HNParent context

    • Another interesting data structure related to skiplists but not mentioned here are zip trees: https://arxiv.org/abs/1806.06726 The are a tree-based version of skiplists and thus more suited to functional programming / immutable datastructures.

      anfelorView on HNParent context

    • I would also recommend Koen Claessen's simplified finger trees (https://dl.acm.org/doi/abs/10.1145/3406088.3409026) and Zip trees (https://arxiv.org/pdf/1806.06726.pdf) for purely functional skip lists.

      anfelorView on HNParent context

  2. Let's Talk SkipList 1 comment
    • There is also a nice new datastructure called Zip Trees [1] which is isomorphic to skip lists in the sense that it performs exactly the same comparisons on insertion/deletion (but it can skip some redundant ones). I would expect zip trees to be faster than skip lists in…

      anfelorView on HNParent context

    • All of those operations are achievable when replacing sqrt with log by using Skip lists (https://en.wikipedia.org/wiki/Skip_list), and probably with Zip trees as well (https://arxiv.org/abs/1806.06726). That being said, the overload of a complex data structure might multiply the…

      Labo333View on HNParent context

  3. Zip Trees 1 comment
    • If you’re on a phone, here’s an HTML version of the paper https://www.arxiv-vanity.com/papers/1806.06726/

      bfirshView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.