Priority Queue

Priority Queue

In der Informatik ist eine Vorrangwarteschlange (auch Prioritätswarteschlange oder engl. priority queue genannt) eine spezielle abstrakte Datenstruktur, genauer eine erweiterte Form einer Warteschlange. Den Elementen, die in die Warteschlange gelegt werden, wird ein Schlüssel mitgegeben, der die Reihenfolge der Abarbeitung der Elemente bestimmt.

Inhaltsverzeichnis

Operationen

Vorrangwarteschlangen müssen die Operationen

  • insert, zum Einfügen eines Elementes und
  • extractMin, zur Rückgabe und zum Entfernen des Elements mit dem kleinsten Schlüssel (= höchster Priorität)

unterstützen.

Daneben gibt es noch Operationen, die vor allem für Online-Algorithmen wichtig sind:

  • remove entfernen eines Elements
  • decreaseKey den Schlüsselwert verringern (=die Priorität erhöhen)

Implementierung

Die Implementierung von Vorrangwarteschlangen kann über AVL-Bäume erfolgen. Sowohl insert als auch extractMin können dann in O(log n) Zeit ausgeführt werden. Eine andere Möglichkeit besteht in der Verwendung partiell geordneter Bäume (Heaps). Auch hier liegt die Zeitkomplexität bei O(log n).

Beispiele für Datenstrukturen, die Vorrangwarteschlangen effizient implementieren sind

Anwendungen

Prioritätswarteschlangen können für die Implementierung diskreter Ereignissimulationen genutzt werden. Dabei werden zu den jeweiligen Ereignissen als Schlüssel die Zeiten berechnet, das Ereignis-Zeit-Paar in die Vorrangwarteschlange eingefügt und die Vorrangwarteschlange gibt dann das jeweils aktuelle (d.h. als nächstes zu verarbeitende) Ereignis aus.

Greedy-Algorithmen machen ebenfalls von Prioritätswarteschlangen Gebrauch, da dort häufig das Minimum, bzw. Maximum, einer Menge bestimmt werden muss.

Erweiterungen

Neben der klassischen, einendigen Vorrangwarteschlange existieren auch zweiendige. Diese unterstützen zusätzlich eine Operation extractMax, um das Element mit dem größten Schlüssel herauszuziehen. Eine Möglichkeit für die Implementierung solcher Datenstrukturen bieten Doppelheaps. Alternativ können auch Datenstrukturen wie Min-Max-Heaps genutzt werden, die direkt zweiendige Prioritätswarteschlangen unterstützen.

Weblinks


Wikimedia Foundation.

Игры ⚽ Нужно решить контрольную?

Schlagen Sie auch in anderen Wörterbüchern nach:

  • Priority queue — A priority queue is an abstract data type in computer programming. It is exactly like a regular queue or stack data structure, but additionally, each element is associated with a priority . stack: elements are pulled in last in first out order (e …   Wikipedia

  • Double-ended priority queue — Not to be confused with Double ended queue. A double ended priority queue (DEPQ)[1] is an abstract data type similar to a priority queue except that it allows for efficient removal of both the maximum and minimum element. It is a data structure… …   Wikipedia

  • Queue — can mean: * Queue area, where a line of people wait. The verb queue means to form a line, and to wait for services. Queue is also the name of this line * Queueing theory, the study of waiting lines * Queue (data structure), in computing, a type… …   Wikipedia

  • Queue (data structure) — A queue (pronounced /kjuː/) is a particular kind of collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and… …   Wikipedia

  • Priority — may refer to: Priority date, a concept of establishing waiting times in the immigration process by United States Department of State Priority level, the priority of emergency communications Priority Records, a record label started in 1985 and… …   Wikipedia

  • queue management —    Queue management sorts out requests from the network by priority …   IT glossary of terms, acronyms and abbreviations

  • queue — [[t]kju͟ː[/t]] queues, queuing, queued (queueing can also be used as the continuous form.) 1) N COUNT: oft N for n, N of n A queue is a line of people or vehicles that are waiting for something. [mainly BRIT] I watched as he got a tray and joined …   English dictionary

  • queue —    Excessive demand on a system at any given point in time creates queues, which are lists of items waiting for processing in a predefined order (i.e., LIFO, FIFO, or priority) …   IT glossary of terms, acronyms and abbreviations

  • Double-ended queue — Not to be confused with Double ended priority queue. In computer science, a double ended queue (dequeue, often abbreviated to deque, pronounced deck) is an abstract data structure that implements a queue for which elements can only be added to or …   Wikipedia

  • Command queue — A command queue is a queue for delaying the execution of commands, usually either in order of priority or on a first in first out basis.[1] They are often useful in synchronous applications, where a command executor may receive a new command… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”