Update the comments of bubble sort

and insertion sort
This commit is contained in:
krahets
2023-05-22 23:05:37 +08:00
parent 5b406666d8
commit f6d290d903
36 changed files with 119 additions and 119 deletions

View File

@ -48,9 +48,9 @@ func quadratic(n: Int) -> Int {
/* */
func bubbleSort(nums: inout [Int]) -> Int {
var count = 0 //
// n-1, n-2, ..., 1
// [0, i]
for i in stride(from: nums.count - 1, to: 0, by: -1) {
//
// [0, i]
for j in 0 ..< i {
if nums[j] > nums[j + 1] {
// nums[j] nums[j + 1]