Top Qs
Timeline
Chat
Perspective
Brodal queue
Optimal data structure for priority queue operations From Wikipedia, the free encyclopedia
Remove ads
In computer science, the Brodal queue is a heap/priority queue structure with very low worst case time bounds: for insertion, find-minimum, meld (merge two queues) and decrease-key and for delete-minimum and general deletion. They are the first heap variant to achieve these bounds without resorting to amortization of operational costs. Brodal queues are named after their inventor Gerth Stølting Brodal.[1]
While having better asymptotic bounds than other priority queue structures, they are, in the words of Brodal himself, "quite complicated" and "[not] applicable in practice."[1] Brodal and Okasaki describe a persistent (purely functional) version of Brodal queues.[2]
Remove ads
Definition
A Brodal queue is a set of two trees and and 5 guides. The definition of the guide data structure can be found in the following section. For both trees, each node has a rank, this rank is useful for later operations and intuitively corresponds to the logarithm of the size of the subtree rooted in the node. We note the number of children of the node with rank . We will also use for the root of tree and for the root of tree . At each given time, every subtree rooted in a node needs to fulfill these 5 invariants :
- : If is a leaf, then ,
- : ,
- : If , then ,
- : we highlight that ,
- : or .
Here guaranties us that the size of the subtree rooted in a node is at least exponential to the rank of that node. In addition, bounds the number of children of each rank for a given node, this implies that all nodes have rank and degrees in .
In a Brodal queue, not every node will have a bigger value than its parent, the nodes vialoating this condition will be called violating nodes. However, we want to keep the number of violating nodes relatively small. To keep track of violating nodes, we create for each node two sets and of nodes larger than . Intuitively, are the nodes larger of with large rank (such that if ), and are the nodes with small rank (). These sets are implemented using doubly linked list meanung they have an order. In particular, all violating nodes added to are added at the front of the list, and all violating nodes added to are inserted next to a node of same rank. The and lists fulfill these 5 invariants (we let denote the number of nodes in of rank ):
- :
- : If then
- : If then there exist a node such that
- :
- : By denoting , we have: for a certain constant .
Remove ads
The guide data structure
Summarize
Perspective
This definition is based on the definition from Brodal's paper[1].
We assume that we have a sequence of variables and we want to make sure that for some threshold . The only operation allowed is which decreases by at least 2 and increases by at most 1. We can assume without loss of generality that reduces by 2 and increases by 1.
If a is increased by one, the goal of the guide is to tell us on which indices to apply in order to respect the threshold. The guide is only allowed to make calls to the function for each increase.
The guide has access to another sequence such that and . As long as after the increase of we have we do not need to ask help from our guide since is "far" bellow . However, if before the increase, then we have after the change.
To simplify the explanation, we can assume that , so that . The guide will create blocks in the sequence of of form where we allow there to be no . The guide maintains the invariant that each element which isn't in a block is either a or a . For example, here are the blocks for a sequence of .
The guide is composed of 3 arrays :
- the array of
- the array of
- an array of pointers where all the for which are in the same block will point to the same memory cell containing a value. If a is not in a block, then points to a memory cell containing .
With this definition, a guide has two important properties :
- For each element in a block, we can find the most left element of the block in time .
- We can destroy a block in time by assigning to the memory cell pointed to by each element of the block.
This way, the guide is able to decide which indices to in time . Here is an example :
To reestablish the blocks, the pointers of the 1 and 0 added to the first block now point to the same cell as all the other elements from the first block, and the value of the second block's cell is changed to . In the previous example, only two operations were needed, this is actually the case for all instances. Therefore, the queue only needs operations to reestablish the property.
Remove ads
Summary of running times
Here are time complexities[3] of various heap data structures. The abbreviation am. indicates that the given complexity is amortized, otherwise it is a worst-case complexity. For the meaning of "O(f)" and "Θ(f)" see Big O notation. Names of operations assume a min-heap.
- For persistent heaps (not supporting decrease-key), a generic transformation reduces the cost of meld to that of insert, while the new cost of delete-min is the sum of the old costs of delete-min and meld.[9] Here, it makes meld run in Θ(1) time (amortized, if the cost of insert is) while delete-min still runs in O(log n). Applied to skew binomial heaps, it yields Brodal-Okasaki queues, persistent heaps with optimal worst-case complexities.[8]
- Brodal queues and strict Fibonacci heaps achieve optimal worst-case complexities for heaps. They were first described as imperative data structures. The Brodal-Okasaki queue is a persistent data structure achieving the same optimum, except that decrease-key is not supported.
Remove ads
Gerth Stølting Brodal
Gerth Stølting Brodal is a professor at the University of Aarhus, Denmark.[19] He is best known for the Brodal queue.
References
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads