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

@ -0,0 +1,26 @@
=begin
File: insertion_sort.rb
Created Time: 2024-04-02
Author: Cy (3739004@gmail.com), Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
=end
### 插入排序 ###
def insertion_sort(nums)
n = nums.length
# 外迴圈:已排序區間為 [0, i-1]
for i in 1...n
base = nums[i]
j = i - 1
# 內迴圈:將 base 插入到已排序區間 [0, i-1] 中的正確位置
while j >= 0 && nums[j] > base
nums[j + 1] = nums[j] # 將 nums[j] 向右移動一位
j -= 1
end
nums[j + 1] = base # 將 base 賦值到正確位置
end
end
### Driver Code ###
nums = [4, 1, 3, 1, 5, 2]
insertion_sort(nums)
puts "插入排序完成後 nums = #{nums}"