Module implementing various data structures
An implementation of a treap. Note that lower priority elements are at the top. Loosely based on the description in “Randomized Algorithms” by Motwani and Raghavan. All mistakes are mine
Methods
Returns the join of self and T2, destroys the heap property of both in the proccess. It assumes T1<=T2
Returns the maximum value at the tree hanging from node as a root
Returns the minimum value at the tree hanging from node as a root
Moves the node to the root, but breaks the heap property in the proccess. Afterwards a splitting a this vertex is trivial
Returns a new treap conaining self, the node and the treap T2. The original treaps, self and T2 no longer satisfy the heap property.
Returns the predecessor of a node
Restores the heap property by rotating the node upwards if necessary
Restores the heap property by rotating the node downwards if necessary.
Splits the treap at the given key value. Note that the old treap no longer satisfies the heap property; should be destroyed but it is difficult and undesirable to do so in Python.
Splits the treap a the given node.
Returns the succesor of node