Skip to content

Commit 3984ad1

Browse files
committed
基数排序
1 parent f058535 commit 3984ad1

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Radix Sort/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
# Radix Sort
2+
# 基数排序
23

34
Radix sort is a sorting algorithm that takes as input an array of integers and uses a sorting subroutine( that is often another efficient sorting algorith) to sort the integers by their radix, or rather their digit. Counting Sort, and Bucket Sort are often times used as the subroutine for Radix Sort.
5+
基数排序是一种排序算法,它将整数数组作为输入,并使用排序子程序(通常是另一种有效的排序算法)来按整数基数或者它们的数字对整数进行排序。 Counting Sort和Bucket Sort通常用作Radix Sort的子程序。
46

57
## Example
8+
## 例子
69

710
* Input Array: [170, 45, 75, 90, 802, 24, 2, 66]
811
* Output Array (Sorted): [2, 24, 45, 66, 75, 90, 170, 802]
912

1013
### Step 1:
14+
### 第一步:
15+
1116
The first step in this algorithm is to define the digit or rather the "base" or radix that we will use to sort.
1217
For this example we will let radix = 10, since the integers we are working with in the example are of base 10.
18+
此算法的第一步是定义数字,或者更确切地说是我们将用于排序的“基数”或基数。
19+
对于这个例子,我们将radix = 10,因为我们在示例中使用的整数是基数10。
1320

1421
### Step 2:
22+
### 第二步:
23+
1524
The next step is to simply iterate n times (where n is the number of digits in the largest integer in the input array), and upon each iteration perform a sorting subroutine on the current digit in question.
25+
下一步是简单地迭代n次(其中n是输入数组中最大整数中的位数),并且在每次迭代时对当前数字执行排序子程序。
1626

1727
### Algorithm in Action
1828

1929
Let's take a look at our example input array.
30+
我们来看看我们的示例输入数组。
2031

2132
The largest integer in our array is 802, and it has three digits (ones, tens, hundreds). So our algorithm will iterate three times whilst performing some sorting algorithm on the digits of each integer.
33+
我们数组中的最大整数是802,它有三位数(一,十,百)。 因此,我们的算法将迭代三次,同时对每个整数的数字执行一些排序算法。
2234

2335
* Iteration 1: 170, 90, 802, 2, 24, 45, 75, 66
2436
* Iteration 2: 802, 2, 24, 45, 66, 170, 75, 90
@@ -29,3 +41,6 @@ The largest integer in our array is 802, and it has three digits (ones, tens, hu
2941
See also [Wikipedia](https://en.wikipedia.org/wiki/Radix_Sort).
3042

3143
*Written for the Swift Algorithm Club by Christian Encarnacion*
44+
45+
*作者:Christian Encarnacion*
46+
*翻译:[Andy Ron](https://github.com/andyRon)*

Radix Sort/README_en.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Radix Sort
2+
3+
Radix sort is a sorting algorithm that takes as input an array of integers and uses a sorting subroutine( that is often another efficient sorting algorith) to sort the integers by their radix, or rather their digit. Counting Sort, and Bucket Sort are often times used as the subroutine for Radix Sort.
4+
5+
## Example
6+
7+
* Input Array: [170, 45, 75, 90, 802, 24, 2, 66]
8+
* Output Array (Sorted): [2, 24, 45, 66, 75, 90, 170, 802]
9+
10+
### Step 1:
11+
The first step in this algorithm is to define the digit or rather the "base" or radix that we will use to sort.
12+
For this example we will let radix = 10, since the integers we are working with in the example are of base 10.
13+
14+
### Step 2:
15+
The next step is to simply iterate n times (where n is the number of digits in the largest integer in the input array), and upon each iteration perform a sorting subroutine on the current digit in question.
16+
17+
### Algorithm in Action
18+
19+
Let's take a look at our example input array.
20+
21+
The largest integer in our array is 802, and it has three digits (ones, tens, hundreds). So our algorithm will iterate three times whilst performing some sorting algorithm on the digits of each integer.
22+
23+
* Iteration 1: 170, 90, 802, 2, 24, 45, 75, 66
24+
* Iteration 2: 802, 2, 24, 45, 66, 170, 75, 90
25+
* Iteration 3: 2, 24, 45, 66, 75, 90, 170, 802
26+
27+
28+
29+
See also [Wikipedia](https://en.wikipedia.org/wiki/Radix_Sort).
30+
31+
*Written for the Swift Algorithm Club by Christian Encarnacion*

0 commit comments

Comments
 (0)