Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Priority queue
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Operations == A priority queue has the following operations:<ref>{{Introduction to Algorithms|edition=4|chapter=Chapter 6.5: Priority queues|pages=172–176}}</ref><ref name=":1">{{Cite journal |last1=Rönngren |first1=Robert |last2=Ayani |first2=Rassul |date=1997-04-01 |title=A comparative study of parallel and sequential priority queue algorithms |url=https://dl.acm.org/doi/10.1145/249204.249205 |journal=ACM Trans. Model. Comput. Simul. |volume=7 |issue=2 |pages=157–209 |doi=10.1145/249204.249205 |issn=1049-3301}}</ref><ref name=":2">{{Cite book |last=Ayani |first=R. |chapter=LR-algorithm: Concurrent operations on priority queues |date=December 1990 |title=Proceedings of the Second IEEE Symposium on Parallel and Distributed Processing 1990 |chapter-url=https://ieeexplore.ieee.org/document/143500 |pages=22–25 |doi=10.1109/SPDP.1990.143500|isbn=0-8186-2087-0 }}</ref> {{div col|colwidth=20em}} === Max-priority queue === * ''insert(S, element, priority)'':<ref name=":1" /><ref name=":2" /> add an element to set ''S'' with an associated priority. * ''maximum(S)'': return the element with ''highest priority''. *: This is also known as "''find_max''". * ''extract_max(S)'': remove the element from set ''S'' with ''highest priority'', and return it. *: This is also known as "''delete''",<ref name=":1" /> or "''extract''".<ref name=":2" /> * ''increase_key(S, element, k)'': increase the associated priority with an element to the new value ''k''. === Min-priority queue === * ''insert(S, element, priority)'':<ref name=":1" /><ref name=":2" /> add an element to set ''S'' with an associated priority. * ''minimum(S)'': return the element with ''lowest priority''. *: This is also known as "''find_min''". * ''extract_min(S)'': remove the element from set ''S'' with ''lowest priority'', and return it. *: This is also known as "''delete''",<ref name=":1" /> or "''extract''".<ref name=":2" /> * ''decrease_key(S, element, k)'': decrease the associated priority with an element to the new value ''k''. {{div col end}} [[Stack (abstract data type)|Stacks]] and [[Queue (abstract data type)|queues]] can be implemented as particular kinds of priority queues, with the priority determined by the order in which the elements are inserted. In a stack, the priority of each inserted element is monotonically increasing; thus, the last element inserted is always the first retrieved. In a queue, the priority of each inserted element is monotonically decreasing; thus, the first element inserted is always the first retrieved. In some implementations, if two elements have the same priority, they are served in the same order in which they were enqueued. In other implementations, the order of elements with the same priority is undefined.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)