Radix Sort
Posted jasperzhao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Radix Sort相关的知识,希望对你有一定的参考价值。
To illustrate the radix sort algorithm we will sort the sequence S0 = {32, 100, 11, 554, 626, 122, 87, 963, 265, 108, 9}. We start by distributing elements of S0 by the value of 0-place digit (the one‘s place):
bucket 1: 11
bucket 2: 32, 122
bucket 3: 963
bucket 4: 554
bucket 5: 265
bucket 6: 626
bucket 7: 87
bucket 8: 108
bucket 9: 9
Stitch the bucket lists to create S1 = {100, 11, 32, 122, 963, 554, 265, 626, 87, 108, 9}. Distribute elements of S1 by the value of 1-place digit (the ten‘s place):
bucket 1: 11
bucket 2: 122, 626
bucket 3: 32
bucket 4:
bucket 5: 554
bucket 6: 963, 265
bucket 7:
bucket 8: 87
bucket 9:
Stitch the bucket lists to create S2 = {100, 108, 9, 11, 122, 626, 32, 554, 963, 265, 87}. Distribute elements of S2 by the value of 2-place digit (the hundred‘s place):
bucket 1: 100, 108, 122
bucket 2: 265
bucket 3:
bucket 4:
bucket 5: 554
bucket 6: 626
bucket 7:
bucket 8:
bucket 9: 963
Stitch the bucket lists to create S3 = {9, 11, 32, 87, 100, 108, 122, 265, 554, 626, 963}. The list is sorted.
以上是关于Radix Sort的主要内容,如果未能解决你的问题,请参考以下文章