python3 快速排序
来源:互联网 发布:mac 查找pip安装路径 编辑:程序博客网 时间:2024/05/21 20:30
脚踏实地,好好学算法
# 快速排序法# 数据源source = [12, 4, 67, 2, 34, 11, 89, 45, 76, 29]num = len(source)left_handler = 0right_handler = num-1while 1: if source[left_handler] > source[right_handler]: # 前者比较大 交换结内容 temp = source[left_handler] source[left_handler] = source[right_handler] source[right_handler] = temp right_handler -= 1 if left_handler == right_handler: print(source) left_handler += 1 right_handler = num-1 if left_handler == num-1: breakprint(source)输出结果
每一步的结果
[2, 4, 67, 11, 34, 12, 89, 45, 76, 29]
[2, 4, 67, 11, 34, 12, 89, 45, 76, 29]
[2, 4, 11, 12, 34, 29, 89, 45, 76, 67]
[2, 4, 11, 12, 34, 29, 89, 45, 76, 67]
[2, 4, 11, 12, 29, 34, 89, 45, 76, 67]
[2, 4, 11, 12, 29, 34, 89, 45, 76, 67]
[2, 4, 11, 12, 29, 34, 45, 67, 76, 89]
[2, 4, 11, 12, 29, 34, 45, 67, 76, 89]
[2, 4, 11, 12, 29, 34, 45, 67, 76, 89]
结果
[2, 4, 11, 12, 29, 34, 45, 67, 76, 89]
0 0
- python3 快速排序
- 快速排序代码python3
- python3字典排序
- Python3.×实现选择排序
- python3字典排序
- python3 冒泡排序
- 排序算法 python3
- 归并排序(python3)
- Python3中list排序
- 选择排序Python3实现
- Python3 列表自定义排序
- Python3.x快速入门学习
- python3 快速上手(总结)
- Python3 快速入门(一)
- Python3 快速入门(二)
- python3快速入门语法教程
- Python3 爬虫快速入门攻略
- 快速排序
- Android Espresso 测试框架介绍
- Get Apache, PHP working on macOS Sierra
- 数据库常用SQL语句
- http://blog.csdn.net/qq_27093465/article/details/52857307
- ITEXT 页眉页脚页码三件套
- python3 快速排序
- 让图片在DIV容器里面水平垂直居中的方法
- typeAliases 元素
- 美团DSP广告策略实践
- hashMap 分析
- 工厂模式
- iOS 三种打电话方法
- http://blog.csdn.net/lilibaobei1314/article/details/34826783
- ffmpeg读取文件速度的控制