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!
=== Using a priority queue to sort === The [[operational semantics|semantics]] of priority queues naturally suggest a sorting method: insert all the elements to be sorted into a priority queue, and sequentially remove them; they will come out in sorted order. This is actually the procedure used by several [[sorting algorithm]]s, once the layer of [[abstraction (computer science)|abstraction]] provided by the priority queue is removed. This sorting method is equivalent to the following sorting algorithms: {|class="wikitable sortable" ! Name !! Priority Queue Implementation !! Best !! Average !! Worst |- align="center" | [[Heapsort]] | [[Heap (data structure)|Heap]] |style="background:#dfd"|''n'' log ''n'' |style="background:#dfd"|''n'' log ''n'' |style="background:#dfd"|''n'' log ''n'' |- align="center" | [[Smoothsort]] | Leonardo Heap |style="background:#dfd"|''n'' |style="background:#dfd"|''n'' log ''n'' |style="background:#dfd"|''n'' log ''n'' |- align="center" | [[Selection sort]] | Unordered [[Array#In computer science|Array]] |style="background:#fdd"|''n<sup>2</sup>'' |style="background:#fdd"|''n<sup>2</sup>'' |style="background:#fdd"|''n<sup>2</sup>'' |- align="center" | [[Insertion sort]] | Ordered [[Array#In computer science|Array]] |style="background:#dfd"|''n'' |style="background:#fdd"|''n<sup>2</sup>'' |style="background:#fdd"|''n<sup>2</sup>'' |- align="center" | [[Tree sort]] | [[Self-balancing binary search tree]] |style="background:#dfd"|''n'' log ''n'' |style="background:#dfd"|''n'' log ''n'' |style="background:#dfd"|''n'' log ''n'' |}
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)