fix: stack_operations.png, bubble_sort.py

This commit is contained in:
Yudong Jin 2023-01-18 19:09:56 +08:00
parent 8ba1f64710
commit fc221b19da
3 changed files with 4 additions and 4 deletions

View file

@ -12,7 +12,7 @@ from include import *
def bubble_sort(nums): def bubble_sort(nums):
n = len(nums) n = len(nums)
# 外循环:待排序元素数量为 n-1, n-2, ..., 1 # 外循环:待排序元素数量为 n-1, n-2, ..., 1
for i in range(n - 1, -1, -1): for i in range(n - 1, 0, -1):
# 内循环:冒泡操作 # 内循环:冒泡操作
for j in range(i): for j in range(i):
if nums[j] > nums[j + 1]: if nums[j] > nums[j + 1]:
@ -23,7 +23,7 @@ def bubble_sort(nums):
def bubble_sort_with_flag(nums): def bubble_sort_with_flag(nums):
n = len(nums) n = len(nums)
# 外循环:待排序元素数量为 n-1, n-2, ..., 1 # 外循环:待排序元素数量为 n-1, n-2, ..., 1
for i in range(n - 1, -1, -1): for i in range(n - 1, 0, -1):
flag = False # 初始化标志位 flag = False # 初始化标志位
# 内循环:冒泡操作 # 内循环:冒泡操作
for j in range(i): for j in range(i):

View file

@ -100,7 +100,7 @@ comments: true
def bubble_sort(nums): def bubble_sort(nums):
n = len(nums) n = len(nums)
# 外循环:待排序元素数量为 n-1, n-2, ..., 1 # 外循环:待排序元素数量为 n-1, n-2, ..., 1
for i in range(n - 1, -1, -1): for i in range(n - 1, 0, -1):
# 内循环:冒泡操作 # 内循环:冒泡操作
for j in range(i): for j in range(i):
if nums[j] > nums[j + 1]: if nums[j] > nums[j + 1]:
@ -288,7 +288,7 @@ comments: true
def bubble_sort_with_flag(nums): def bubble_sort_with_flag(nums):
n = len(nums) n = len(nums)
# 外循环:待排序元素数量为 n-1, n-2, ..., 1 # 外循环:待排序元素数量为 n-1, n-2, ..., 1
for i in range(n - 1, -1, -1): for i in range(n - 1, 0, -1):
flag = False # 初始化标志位 flag = False # 初始化标志位
# 内循环:冒泡操作 # 内循环:冒泡操作
for j in range(i): for j in range(i):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB