Skip to content

Commit 6f5a407

Browse files
committed
bucket sort docs
1 parent 92fceb0 commit 6f5a407

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/9.bucket_sort.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 桶排序
2+
3+
## 概述
4+
桶排序是计数排序的升级版。它利用了函数的映射关系,高效与否的关键就在于这个映射函数的确定。为了使桶排序更加高效,我们需要做到这两点:
5+
1. 在额外空间充足的情况下,尽量增大桶的数量
6+
2. 使用的映射函数能够将输入的 N 个数据均匀的分配到 K 个桶中
7+
8+
同时,对于桶中元素的排序,选择何种比较排序算法对于性能的影响至关重要。
9+
10+
## 算法步骤
11+
1. 设置固定数量的空桶。
12+
2. 把数据放到对应的桶中。
13+
3. 对每个不为空的桶中数据进行排序
14+
4. 拼接不为空的桶中数据,得到结果

0 commit comments

Comments
 (0)