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
Pigeonhole sort
(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!
==Example== Suppose one were sorting these value pairs by their first element: * (5, "hello") * (3, "pie") * (8, "apple") * (5, "king") For each value between 3 and 8 we set up a pigeonhole, then move each element to its pigeonhole: * 3: (3, "pie") * 4: * 5: (5, "hello"), (5, "king") * 6: * 7: * 8: (8, "apple") The pigeonhole array is then iterated over in order, and the elements are moved back to the original list. The difference between pigeonhole sort and counting sort is that in counting sort, the auxiliary array does not contain lists of input elements, only counts: * 3: 1 * 4: 0 * 5: 2 * 6: 0 * 7: 0 * 8: 1 For arrays where ''N'' is much larger than ''n'', [[bucket sort]] is a generalization that is more efficient in space and time.
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)