You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Radix Sort/README.md
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,36 @@
1
1
# Radix Sort
2
+
# 基数排序
2
3
3
4
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.
The first step in this algorithm is to define the digit or rather the "base" or radix that we will use to sort.
12
17
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。
13
20
14
21
### Step 2:
22
+
### 第二步:
23
+
15
24
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.
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.
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.
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