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
Radix 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!
=== Least significant digit === Input list: :'''[170, 45, 75, 90, 2, 802, 2, 66]''' Starting from the rightmost (last) digit, sort the numbers based on that digit: :'''[{17<u>0</u>, 9<u>0</u>}, {<u>2</u>, 80<u>2</u>, <u>2</u>}, {4<u>5</u>, 7<u>5</u>}, {6<u>6</u>}]''' Sorting by the next left digit: :'''[{''<u>0</u>''2, 8<u>0</u>2, ''<u>0</u>''2}, {<u>4</u>5}, {<u>6</u>6}, {1<u>7</u>0, <u>7</u>5}, {<u>9</u>0}]''' :<small>Notice that an implicit digit ''0'' is prepended for the two 2s so that 802 maintains its position between them.</small> And finally by the leftmost digit: :'''[{''<u>0</u>0''2, ''<u>0</u>0''2, ''<u>0</u>''45, ''<u>0</u>''66, ''<u>0</u>''75, ''<u>0</u>''90}, {<u>1</u>70}, {<u>8</u>02}]''' :<small>Notice that a ''0'' is prepended to all of the 1- or 2-digit numbers.</small> Each step requires just a single pass over the data, since each item can be placed in its bucket without comparison with any other element. Some radix sort implementations allocate space for buckets by first counting the number of keys that belong in each bucket before moving keys into those buckets. The number of times that each digit occurs is stored in an [[Array data type|array]]. Although it is always possible to pre-determine the bucket boundaries using counts, some implementations opt to use dynamic memory allocation instead.
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)