Merge pull request #233 from mellowrsa/patch-1

Update time_complexity.md
pull/236/head
Yudong Jin 2 years ago committed by GitHub
commit cbede422e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1434,11 +1434,14 @@ $$
for (int i = n - 1; i > 0; i--) {
// 内循环:冒泡操作
for (int j = 0; j < i; j++) {
// 交换 nums[j] 与 nums[j + 1]
int tmp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = tmp;
count += 3; // 元素交换包含 3 个单元操作
if (nums[j] > nums [j + 1])
{
// 交换 nums[j] 与 nums[j + 1]
int tmp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = tmp;
count += 3; // 元素交换包含 3 个单元操作
}
}
}

Loading…
Cancel
Save