mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 12:16:29 +08:00
fix: stack_operations.png, bubble_sort.py
This commit is contained in:
parent
8ba1f64710
commit
fc221b19da
3 changed files with 4 additions and 4 deletions
|
@ -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):
|
||||||
|
|
|
@ -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 |
Loading…
Reference in a new issue