Skip to main content

Zip Trees

  • Conference paper
  • First Online:
Algorithms and Data Structures (WADS 2019)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 11646))

Included in the following conference series:

Abstract

We introduce the zip tree, (Zip: “To move very fast.”) 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 ties broken in favor of smaller keys. Zip trees are essentially treaps [8], 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 by Stephenson [10], Martínez and Roura [5], and Sprugnoli [9].

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 [7], and simplify Dean and Jones’ mapping between skip lists and binary search trees [2].

Research at Princeton University partially supported by an innovation research grant from Princeton and a gift from Microsoft.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Seidel and Aragon [8] hinted at the possibility of doing insertions and deletions by unzipping and zipping: in a footnote they say, “In practice it is preferable to approach these operations the other way around. Joins and splits of treaps can be implemented as iterative top-down procedures; insertions and deletions can then be implemented as accesses followed by splits or joins.” But they provide no further details.

  2. 2.

    This issue is not merely theoretical. Reuse of random seeds has led to real-world “denial-of-service” attacks for a number of programming libraries. See http://ocert.org/advisories/ocert-2011-003.html.

References

  1. Chernoff, H.: A measure of asymptotic efficiency for tests of a hypothesis based on the sum of observations. Ann. Math. Stat. 23(4), 493–507 (1952)

    Article  MathSciNet  Google Scholar 

  2. Dean, B.C., Jones, Z.H.: Exploring the duality between skip lists and binary search trees. In: Proceedings of the 45th Annual Southeast Regional Conference, pp. 395–400. ACM Press (2007)

    Google Scholar 

  3. Haeupler, B., Sen, S., Tarjan, R.E.: Rank-balanced trees. ACM Trans. Algorithms 11(4), 1–26 (2015)

    Article  MathSciNet  Google Scholar 

  4. Hibbard, T.N.: Some combinatorial properties of certain trees with applications to searching and sorting. J. ACM 9(1), 13–28 (1962)

    Article  MathSciNet  Google Scholar 

  5. Martínez, C., Roura, S.: Randomized binary search trees. J. ACM 45(2), 288–323 (1998)

    Article  MathSciNet  Google Scholar 

  6. Prodinger, H.: Combinatorics of geometrically distributed random variables: left-to-right maxima. Discrete Math. 153(1–3), 253–270 (1996)

    Article  MathSciNet  Google Scholar 

  7. Pugh, W.: Skip lists: a probabilistic alternative to balanced trees. Commun. ACM 33(6), 668–676 (1990)

    Article  Google Scholar 

  8. Seidel, R., Aragon, C.R.: Randomized search trees. Algorithmica 16(4–5), 464–497 (1996)

    Article  MathSciNet  Google Scholar 

  9. Sprugnoli, R.: Randomly balanced binary trees. Calcolo 17(2), 99–117 (1980)

    Article  MathSciNet  Google Scholar 

  10. Stephenson, C.J.: A method for constructing binary search trees by making insertions at the root. Int. J. Comput. Inf. Sci. 9(1), 15–29 (1980)

    Article  Google Scholar 

  11. Tarjan, R.E., Levy, C.C., Timmel, S.: Zip trees. arXiv e-prints arXiv:1806.06726 (2018)

  12. Tarjan, R.E.: Data structures and network algorithms. Society for Industrial and Applied Mathematics, Philadelphia (1983)

    Book  Google Scholar 

  13. Timmel, S.: Zip trees: a new approach to concurrent binary search trees. http://arks.princeton.edu/ark:/88435/dsp01gh93h214f. Senior Thesis, Department of Mathematics, Princeton University (2017)

  14. Vuillemin, J.: A unifying look at data structures. Commun. ACM 23(4), 229–239 (1980)

    Article  MathSciNet  Google Scholar 

Download references

Acknowledgements

We thank Dave Long for carefully reading the manuscript and offering many useful suggestions, most importantly helping us simplify the iterative insertion and deletion algorithms that appear in the extended version of this paper [11]. We thank Sebastian Wild for correcting the bound on expected node depth in treaps in Sect. 2 and for his ideas on breaking rank ties. Finally, we are grateful to Dominik Kempa for providing us with C++ zip-tree implementations, benchmarks, and general comments.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Caleb C. Levy .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Tarjan, R.E., Levy, C.C., Timmel, S. (2019). Zip Trees. In: Friggstad, Z., Sack, JR., Salavatipour, M. (eds) Algorithms and Data Structures. WADS 2019. Lecture Notes in Computer Science(), vol 11646. Springer, Cham. https://doi.org/10.1007/978-3-030-24766-9_41

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-24766-9_41

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-24765-2

  • Online ISBN: 978-3-030-24766-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics