ArticleslgStudy

computer science

Queap

Queap 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 Queap rather than just read about it. In short: In computer science, a queap is a priority queue data structure. The data structure allows insertions and deletions of arbitrary elements, as well as retrieval of the highest-priority element.

Queap — main illustration
Queap — illustration

Key takeaways

  • Queap 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 Queap to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Queap from memory before moving on to harder problems.

Reference excerpt

In computer science, a queap is a priority queue data structure. The data structure allows insertions and deletions of arbitrary elements, as well as retrieval of the highest-priority element. Each deletion takes amortized time logarithmic in the number of items that have been in the structure for a longer time than the removed item. Insertions take constant amortized time. The data structure consists of a doubly linked list and a 2–4 tree data structure, each modified to keep track of its minimum-priority element. The basic operation of the structure is to keep newly inserted elements in the doubly linked list, until a deletion would remove one of the list items, at which point they are all moved into the 2–4 tree. The 2–4 tree stores its elements in insertion order, rather than the more conventional priority-sorted order. Both the data structure and its name were devised by John Iacono and Stefan Langerman.

Description A queap is a priority queue that inserts elements in O(1) amortized time, and removes the minimum element in O(log(k + 2)) if there are k items that have been in the heap for a longer time than the element to be extracted. The queap has a property called the queueish property: the time to search for element x is O(lg q(x)) where q(x) is equal to n − 1 − w(x) and w(x) is the number of distinct items that has been accessed by operations such as searching, inserting, or deleting. q(x) is defined as how many elements have not been accessed since x's last access. Indeed, the queueish property is the complement of the splay tree working set property: the time to search for element x is O(lg w(x)). A queap can be represented by two data structures: a doubly linked list and a modified version of 2–4 tree. The doubly linked list, L, is used for a series of insert and locate-min operations. The queap keeps a pointer to the minimum element stored in the list. To add element x to list l, the element x is added to the end of the list and a bit variable in element x is set to one. This operation is done to determine if the element is either in the list or in a 2–4 tree. A 2–4 tree is used when a delete operation occurs. If the item x is already in tree T, the item is removed using the 2–4 tree delete operation. Otherwise, the item x is in list L (done by checking if the bit variable is set). All the elements stored in list L are then added to the 2–4 tree, setting the bit variable of each element to zero. x is then removed from T. A queap uses only the 2–4 tree structure properties, not a search tree. The modified 2–4 tree structure is as follows. Suppose list L has the following set of elements: x 1 , x 2 , x 3 , … , x k {\displaystyle x_{1},x_{2},x_{3},\dots ,x_{k}} . When the deletion operation is invoked, the set of elements stored in L is then added to the leaves of the 2–4 tree in that order, proceeded by a dummy leaf containing an infinite key. Each internal node of T has a pointer h v {\displaystyle h_{v}} , which points to the smallest item in subtree v. Each internal node on path P from the root to x 0 {\displaystyle x_{0}} has a pointer c v {\displaystyle c_{v}} , which points to the smallest key in T − T v − { r } {\displaystyle T-T_{v}-\{r\}} . The h v {\displaystyle h_{v}} pointers of each internal node on path P are ignored. The queap has a pointer to c x 0 {\displaystyle c_{x_{0}}} , which points to the smallest element in T. An application of queaps includes a unique set of high priority events and extraction of the highest priority event for processing.

Operations Let minL be a pointer that points to the minimum element in the doubly linked list L, c x 0 {\displaystyle c_{x_{0}}} be the minimum element stored in the 2–4 tree, T, k be the number of elements stored in T, and n be the total number of elements stored in queap Q. The operations are as follows: New(Q): Initializes a new empty queap.

Initialize an empty doubly linked list L and 2–4 tree T. Set k and n to zero. Insert(Q, x): Add the element x to queap Q.

Insert the element x in list L. Set the bit in element x to one to demonstrate that the element is in the list L. Update the minL pointer if x is the smallest element in the list. Increment n by 1. Minimum(Q): Retrieve a pointer to the smallest element from queap Q.

If key(minL) < key( c x 0 {\displaystyle c_{x_{0}}} ), return minL. Otherwise return c x 0 {\displaystyle c_{x_{0}}} . Delete(Q, x): Remove element x from queap Q.

… excerpt ends here. Continue reading the full article.

Illustrations

Queap: A queap Q with k = 6 and n = 9
A queap Q with k = 6 and n = 9
Queap illustration

Worked examples

Example 1 — a first encounter with Queap

Start with the simplest possible case. Write down what Queap 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 Queap 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 Queap 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 Queap

In research
Queap 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 Queap 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
Queap is common in secondary-school and first-year university syllabi. It links to neighbouring topics Algorithmic information theory, Amortized data structures, Heaps (data structures), so understanding it makes those chapters shorter.
In everyday life
Look for Queap 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.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Queap in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Queap 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 Queap out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Queap in simple terms?

In computer science, a queap is a priority queue data structure. The data structure allows insertions and deletions of arbitrary elements, as well as retrieval of the highest-priority element.

Why does Queap 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 Queap?

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

Tags

  • Algorithmic information theory
  • Amortized data structures
  • Heaps (data structures)

Keep exploring