e01.org

Brodal queue

In computer science, the Brodal queue is a heap/priority queue structure with very low worst case time bounds: O(1) for insertion, find-minimum, meld (merge two queues) and decrease-key and O(\mathrm{log}(n)) 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. 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." Brodal and Okasaki describe a persistent (purely functional) version of Brodal queues.

In computer science, the Brodal queue is a heap/priority queue structure with very low worst case time bounds: O(1) for insertion, find-minimum, meld (merge two queues) and decrease-key and O(\mathrm{log}(n)) 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. 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." Brodal and Okasaki describe a persistent (purely functional) version of Brodal queues. \text{LEAF-RANK} : If x is a leaf, then \text{rank}(x) = 0 , \text{PARENT-RANK} : \text{rank}(x) , \text{NEXT-RANK-ARITY} : If \text{rank}(x) > 0 , then \text{arity}_{\text{rank}(x)-1}(x) \geqslant 2 , \text{ARITY-BOUND} : \text{arity}_i(x) \in \{0, 2, 3, \dots, 7\} we highlight that \text{arity}_i(x) \neq 1 , \text{ROOT-RANK} : T_2 = \emptyset or \text{rank}(t_1) \leqslant \text{rank}(t_2) . Here \text{NEXT-RANK-ARITY} guarantees us that the size of the subtree rooted in a node is at least exponential to the rank of that node. In addition, \text{ARITY-BOUND} bounds the number of children of each rank for a given node, this implies that all nodes have rank and degrees in O(\log n) . 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 V(x) and W(x) of nodes larger than x . Intuitively, V(x) are the nodes larger of x with large rank (such that y \in V(x) if \text{rank}(y) \geqslant \text{rank}(t_1) ), and W(x) are the nodes with small rank ( \text{rank}(y) ). These sets are implemented using doubly linked list meaning they have an order. In particular, all violating nodes added to V(x) are added at the front of the list, and all violating nodes added to W(x) are inserted next to a node of same rank. We let w_i(x) denote the number of nodes in W(x) of rank i The V(x) and W(x) lists fulfill these 5 invariants (we will call the \text{SETS} invariants): \text{MINIMUM-NODE} : t_1 = \min (T_1 \cup T_2) \text{VIOLATING-CONDITION} : If y \in V(x) \cup W(x) then y \geqslant x \text{PARENT-VIOLATING} : If y then there exist a node x \neq y such that y \in V(x) \cup W(x) \text{W-RANK-BOUND} : w_i(x) \leqslant 6 \text{V-RANK-BOUND} : By denoting V(x) = (v_ , \dots, v_2, v_1) , we have: \text{rank}(v_i) \geqslant \left\lfloor \frac{i-1}{\alpha} \right\rfloor for a certain constant \alpha . Since all nodes have rank in O(\log n) the \text{W-RANK-BOUND} and \text{V-RANK-BOUND} , all V(x) and W(x) are in size O(\log n) . We also have some invariants of the roots of the trees T_1 and T_2 : t_1 and t_2 (called the \text{ROOTS} invariants). \text{ROOT-ARITY} : t_i \in \{2, 3, \dots, 7\} \text{ for } i \in \{0, 1, \dots, \text{rank}(t_i)-1\} , \text{V-SIZE-BOUND} : |V(x)| \leqslant \alpha \text{ rank}(t_1) , \text{W-ELEMENTS-RANK} : if y \in W(t_1) , then \text{rank}(y) . The \text{V-SIZE-BOUND} invariant essentially tells us that if we increase the rank of t_1 by one, we have at most \alpha new "large" violations (here large means having a high rank) without violating the \text{V-RANK-BOUND} invariant. On the other hand, the \text{W-ELEMENTS-RANK} invariant tells us that all violations in W(x) are "small", this invariant is true per the definition of W . Maintaining the invariants \text{W-RANK-BOUND} and \text{ROOT-ARITY} is not trivial, to maintain these we will use the \text{DecreaseKey} operation which can be implemented using a guide as defined in the next section. Each time we will call the \text{DecreaseKey} operation, we will essentially : Add the new violation to V(t_1) or W(t_1) depending on the rank of that violation. To avoid V(t_1) and W(t_1) from getting too large, we incrementally do two kinds of transformations: Moving the sons of t_2 to t_1 to increase the rank of t_1 Reducing the number of violations in W(t_1) by replacing two violations of rank k to one violation of rank k+1 The guide has access to another sequence x'_k, \dots, x'_1 such that x_i \leqslant x'_i and x'_i \in \{T-2, T-1, T\} . As long as after the increase of x_j we have x_j \leqslant x'_j we do not need to ask help from our guide since x_j is "far" bellow T . However, if x_j = x'_j before the increase, then we have x_j+1 > x'_j after the change. To simplify the explanation, we can assume that T = 2 , so that x'_i \in \{0, 1, 2\} . The guide will create blocks in the sequence of x'_i of form 2, 1, 1, \dots, 1, 0 where we allow there to be no 1 . The guide maintains the invariant that each element which isn't in a block is either a 1 or a 0 . For example, here are the blocks for a sequence of x'_i . 1, \underline{2, 1, 1, 0}, 1, 1, \underline{2, 0}, \underline{2, 0}, 1, 0, \underline{2, 1, 0} The guide is composed of 3 arrays : x the array of x_k, \dots, x_1 x' the array of x'_k, \dots, x'_1 p an array of pointers where all the p_i for which x'_i are in the same block will point to the same memory cell containing a value. If a x'_i is not in a block, then p_i points to a memory cell containing \bot . 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 O(1) . We can destroy a block in time O(1) by assigning \bot to the memory cell pointed to by each element of the block. This way, the guide is able to decide which indices to \text{REDUCE} in time O(1) . Here is an example : \begin{array}{ll} \underline{2,1,1,0}, \underline{2,1,1,1,0} & \\ \underline{2,1,1,0}, \underline{2,{\color{red}2},1,1,0} & \text{Increment } x'_i \\ \underline{2,1,1,{\color{green}1}}, \underline{{\color{blue}0},2,1,1,0} & \text{REDUCE}\\ \underline{2,1,1,1}, \underline{{\color{green}1},{\color{blue}0},1,1,0} & \text{REDUCE}\\ \underline{2,1,1,1,1,0}, 1,1,0 & \text{reestablish blocks}\\ \end{array} 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 \bot . In the previous example, only two \text{REDUCE} operations were needed, this is actually the case for all instances. Therefore, the queue only needs O(1) operations to reestablish the property. Else, \text{rank}(y) = k+1 . We will cut off x_1, x_2 \text{ and } y , the new rank of y will be one plus the rank of its leftmost son, We replace y by a son on t_1 of rank k+1 , which can be cut off as described in the previous subsection. If the replacement for y becomes a violating node of rank k+1 , we add it to W(t_1) . Finally we make x_1, x_2 \text{ and } y new sons of t_1 as described above. For each priority queue operation that is performed, we increase the rank of t_1 by at least one by moving a constant number of sons of t_2 to t_1 (provided that T_2 \neq \emptyset ). Increasing the rank of t_1 allows us to add violations to V(t_1) while still maintaining all our invariants. If T_2 \neq \emptyset and \text{rank}(t_2) \leqslant \text{rank}(t_1) + 2 we can cut the largest sons of t_2 , link them to t_1 and then make t_2 a son of t_1 . This satisfies all the invariants. Otherwise, we cut off a son of t_2 of rank \text{rank}(t_1) + 2 , delink this son and add the resulting trees to t_1 . If T_2 = \emptyset , we know that t_1 is the node of largest rank, therefore we know that no large violations can be created. \text{Insert}(Q, e) is only a special case of \text{Meld}(Q_1, Q_2) where Q_2 is a queue only containing e and Q_1 = Q . ==Summary of running times== ==Gerth Stølting Brodal== Gerth Stølting Brodal is a professor at the University of Aarhus, Denmark. He is best known for the Brodal queue. ==References==

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Brodal queue". 1768790229. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1333678769

JSON record · API collection · citation policy