随笔分类 - 算法
摘要:def selection_sort(alist): n = len(alist) # 需要进行n-1次选择操作 a = 0 for i in range(n-1): # 记录最小位置 min_index = i exit = i # 从i+1位置到末尾选择出最小数据 for j in range(
阅读全文
摘要:# Start with a list of numbers that ain't sorted numbers=[0,5,1,4,2,8] # Keep track of whether any swaps were made on the previous i teration # If no
阅读全文
摘要:1, 速度很快, 唯一缺陷是计数长度列表和排序的最大数字相等, 如果排序中的数字实在太大了, 创建的列表太长了比如2的32次方 import random def count_sort(li, max_count =21): count = [0 for _ in range(max_count+1
阅读全文
摘要:1、https://visualgo.net/zh 2、https://algorithm-visualizer.org/ 3、https://pythontutor.com/ 我在电脑端试了下都能打开,没架梯子没FQ
阅读全文