Zip tree
≈ 3 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
The zip tree was introduced as a variant of random binary search tree by Robert Tarjan, Caleb Levy, and Stephen Timmel. Zip trees are similar to max treaps except ranks are generated through a geometric distribution and maintain their max-heap property during insertions and deletions through unzipping and zipping rather than tree rotations.
Nodes of the tree contain a distinct, comparable key and a numeric rank. The tree is max heap ordered with respect to the ranks with ties broken in favor of smaller keys. Nodes of the tree must contain distinct keys but allow for duplicate ranks.
The rank tie-breaker favoring smaller keys creates a bias in the tree favoring smaller nodes. A slightly modified zip tree variant, zip-zip trees address this bias by introducing a different tie-breaker with a second rank.
The zip tree was introduced as a variant of random binary search tree by Robert Tarjan, Caleb Levy, and Stephen Timmel. Zip trees are similar to max treaps except ranks are generated through a geometric distribution and maintain their max-heap property during insertions and deletions through unzipping and zipping rather than tree rotations.
Nodes of the tree contain a distinct, comparable key and a numeric rank. The tree is max heap ordered with respect to the ranks with ties broken in favor of smaller keys. Nodes of the tree must contain distinct keys but allow for duplicate ranks.
The rank tie-breaker favoring smaller keys creates a bias in the tree favoring smaller nodes. A slightly modified zip tree variant, zip-zip trees address this bias by introducing a different tie-breaker with a second rank. Then, follow the search path for x in the tree until finding a node u such that u.rank x.key.
Keys must be unique so if at any point v.key = x.key, the search stops and no new node is inserted. Once the search for x is complete, x is inserted in place of the node u. The top node of the path P becomes the left child of x and the top node of Q becomes the right child.
The parent and child pointers between u and u.parent will be updated accordingly with x, and if u was previously the root node, x becomes the new root.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1311791948 under CC BY-SA 4.0; modifications have been made.