Prepare 1.1.0 release (#1274)

* Update bucket_sort.c

* Fix the comments in quick_sort.c

* Update the announce badge

* Sync zh and zh-hant versions

* Update contributors list.

* Sync zh and zh-hant versions.

* Sync zh and zh-hant versions.

* Update the contributors list

* Update the version number
This commit is contained in:
Yudong Jin
2024-04-14 20:46:20 +08:00
committed by GitHub
parent 16942dfe32
commit d484b08c15
43 changed files with 471 additions and 115 deletions

View File

@ -26,6 +26,7 @@ fun forLoopRecur(n: Int): Int {
var res = 0
// 遞: 遞迴呼叫
for (i in n downTo 0) {
// 透過“入堆疊操作”模擬“遞”
stack.push(i)
}
// 迴: 返回結果

View File

@ -18,7 +18,6 @@ fun constant(n: Int): Int {
/* 線性階 */
fun linear(n: Int): Int {
var count = 0
// 迴圈次數與陣列長度成正比
for (i in 0..<n)
count++
return count
@ -55,7 +54,9 @@ fun bubbleSort(nums: IntArray): Int {
for (j in 0..<i) {
if (nums[j] > nums[j + 1]) {
// 交換 nums[j] 與 nums[j + 1]
nums[j] = nums[j + 1].also { nums[j + 1] = nums[j] }
val temp = nums[j]
nums[j] = nums[j + 1]
nums[j + 1] = temp
count += 3 // 元素交換包含 3 個單元操作
}
}
@ -66,8 +67,8 @@ fun bubbleSort(nums: IntArray): Int {
/* 指數階(迴圈實現) */
fun exponential(n: Int): Int {
var count = 0
// 細胞每輪一分為二,形成數列 1, 2, 4, 8, ..., 2^(n-1)
var base = 1
// 細胞每輪一分為二,形成數列 1, 2, 4, 8, ..., 2^(n-1)
for (i in 0..<n) {
for (j in 0..<base) {
count++

View File

@ -13,12 +13,11 @@ fun randomNumbers(n: Int): Array<Int?> {
for (i in 0..<n) {
nums[i] = i + 1
}
val mutableList = nums.toMutableList()
// 隨機打亂陣列元素
mutableList.shuffle()
nums.shuffle()
val res = arrayOfNulls<Int>(n)
for (i in 0..<n) {
res[i] = mutableList[i]
res[i] = nums[i]
}
return res
}