mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Update 10-classical-sorting-algorithms.md
This commit is contained in:
parent
e778f21f6f
commit
5e457ab678
@ -357,7 +357,7 @@ public static int[] merge(int[] arr_1, int[] arr_2) {
|
||||
|
||||
### 算法步骤
|
||||
|
||||
快速排序使用[分治法](https://zh.wikipedia.org/wiki/分治法)(Divide and conquer)策略来把一个序列分为较小和较大的 2 个子序列,然后递回地排序两个子序列。具体算法描述如下:
|
||||
快速排序使用[分治法](https://zh.wikipedia.org/wiki/分治法)(Divide and conquer)策略来把一个序列分为较小和较大的 2 个子序列,然后递归地排序两个子序列。具体算法描述如下:
|
||||
|
||||
1. 从序列中**随机**挑出一个元素,做为 “基准”(`pivot`);
|
||||
2. 重新排列序列,将所有比基准值小的元素摆放在基准前面,所有比基准值大的摆在基准的后面(相同的数可以到任一边)。在这个操作结束之后,该基准就处于数列的中间位置。这个称为分区(partition)操作;
|
||||
@ -738,4 +738,4 @@ public static int[] radixSort(int[] arr) {
|
||||
- <https://en.wikipedia.org/wiki/Sorting_algorithm>
|
||||
- <https://sort.hust.cc/>
|
||||
|
||||
<!-- @include: @article-footer.snippet.md -->
|
||||
<!-- @include: @article-footer.snippet.md -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user