ArticleslgStudy

computer science

Brodal queue

Brodal queue is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Brodal queue rather than just read about it. In short: 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(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.

Key takeaways

  • Brodal queue belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Brodal queue to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Brodal queue from memory before moving on to harder problems.

Reference excerpt

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(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.

Definition A Brodal queue is a set of two trees T1 and T2 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 arityi(x) the number of children of the node x with rank i. We will also use t1 for the root of tree T1 and t2 for the root of tree T2. At each given time, every subtree rooted in a node needs to fulfill these 5 invariants (which will be later called RANK invariants):

LEAF-RANK : If x is a leaf, then rank(x)=0, PARENT-RANK : rank(x)<rank(parent(x)), NEXT-RANK-ARITY : If rank(x)>0, then arityrank(x)−1(x)⩾2, ARITY-BOUND: arityi(x)∈{0,2,3,…,7} we highlight that arityi(x)≠1, ROOT-RANK : T2=∅︀ or rank(t1)⩽rank(t2). Here 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, 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 violating 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∈V(x) if rank(y)⩾rank(t1)), and W(x) are the nodes with small rank (rank(y)<rank(t1)). 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 wi(x) denote the number of nodes in W(x) of rank iThe V(x) and W(x) lists fulfill these 5 invariants (we will call the SETS invariants):

MINIMUM-NODE : t1=min⁡(T1∪T2) VIOLATING-CONDITION : If y∈V(x)∪W(x) then y⩾x PARENT-VIOLATING: If y<parent(y) then there exist a node x≠y such that y∈V(x)∪W(x) W-RANK-BOUND: wi(x)⩽6 V-RANK-BOUND: By denoting V(x)=(v|V(x)|,…,v2,v1), we have: rank(vi)⩾⌊i−1α⌋ for a certain constant α. Since all nodes have rank in O(log⁡n) the W-RANK-BOUND and 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 T1 and T2: t1 and t2 (called the ROOTS invariants).

ROOT-ARITY : ti∈{2,3,…,7} for i∈{0,1,…,rank(ti)−1}, V-SIZE-BOUND: |V(x)|⩽α rank(t1), W-ELEMENTS-RANK: if y∈W(t1), then rank(y)<rank(t1). The V-SIZE-BOUND invariant essentially tells us that if we increase the rank of t1 by one, we have at most α new "large" violations (here large means having a high rank) without violating the V-RANK-BOUND invariant. On the other hand, the W-ELEMENTS-RANKinvariant tells us that all violations in W(x) are "small", this invariant is true per the definition of W. Maintaining the invariants W-RANK-BOUND and ROOT-ARITY is not trivial, to maintain these we will use the DecreaseKey operation which can be implemented using a guide as defined in the next section. Each time we will call the DecreaseKey operation, we will essentially :

Add the new violation to V(t1) or W(t1) depending on the rank of that violation. To avoid V(t1) and W(t1) from getting too large, we incrementally do two kinds of transformations: Moving the sons of t2 to t1 to increase the rank of t1 Reducing the number of violations in W(t1) by replacing two violations of rank k to one violation of rank k+1

The guide data structure This definition is based on the definition from Brodal's paper. We assume that we have a sequence of variables xk,…,x1 and we want to make sure that ∀i⩽k,xi⩽T for some threshold T. The only operation allowed is REDUCE(i) which decreases xi by at least 2 and increases xi+1 by at most 1. We can assume without loss of generality that REDUCE(i) reduces xi by 2 and increases xi+1by 1. If a xj is increased by one, the goal of the guide is to tell us on which indices i to apply REDUCE(i) in order to respect the threshold. The guide is only allowed to make O(1) calls to the REDUCE function for each increase. The guide has access to another sequence x'k,…,x'1 such that xi⩽x'i and x'i∈{T−2,T−1,T}. As long as after the increase of xj we have xj⩽x'j we do not need to ask help from our guide since xj is "far" bellow T. However, if xj=x'j before the increase, then we have xj+1>x'j after the change. To simplify the explanation, we can assume that T=2, so that x'i∈{0,1,2}. The guide will create blocks in the sequence of x'i of form 2,1,1,…,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,2,1,1,0_,1,1,2,0_,2,0_,1,0,2,1,0_ The guide is composed of 3 arrays :

x the array of xk,…,x1 x′the array of x'k,…,x'1 p an array of pointers where all the pi 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 pi points to a memory cell containing ⊥. With this definition, a guide has two important properties :

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Brodal queue

Start with the simplest possible case. Write down what Brodal queue claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Brodal queue before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Brodal queue ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Brodal queue

In research
Brodal queue appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Brodal queue in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Brodal queue is common in secondary-school and first-year university syllabi. It links to neighbouring topics Heaps (data structures), so understanding it makes those chapters shorter.
In everyday life
Look for Brodal queue outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Brodal queue” →

How to study Brodal queue in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Brodal queue means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Brodal queue out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Brodal queue in simple terms?

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(log(n)) for delete-minimum and general deletion. They are the first heap variant to achieve these bounds wi…

Why does Brodal queue matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Brodal queue?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Brodal queue.

Tags

  • Heaps (data structures)

Keep exploring