python的快速排序
来源:互联网 发布:绑定域名和空间 编辑:程序博客网 时间:2024/05/23 12:03
def QuickSort(myList,start,end): #判断low是否小于high,如果为false,直接返回 if start < end: i,j = start,end #设置基准数 base = myList[i] while i < j: #***如果列表后边的数,比基准数大或相等,则前移一位直到有比基准数小的数出现*** while (i < j) and (myList[j] >= base): j = j - 1 ***#如找到,则把第j个元素赋值给第个元素i,此时表中i,j个元素相等*** myList[i] = myList[j] #同样的方式比较前半区 while (i < j) and (myList[i] <= base): i = i + 1 myList[j] = myList[i] #做完第一轮比较之后,列表被分成了两个半区,并且i=j,需要将这个数设置回base myList[i] = base #递归前后半区 QuickSort(myList, start, i - 1) QuickSort(myList, j + 1, end) return myList
阅读全文
0 0
- python的快速排序
- python 写的快速排序
- 快速排序的python实现
- Python--排序--快速排序
- [排序] 快速排序(Python)
- 快速排序、堆排序、归并排序的python实现
- Python实现的快速排序,Very Good!!!
- 快速排序的python和c++
- 快速排序的实现(python)
- python版本的快速排序算法
- 快速排序算法的Python实现
- 快速排序的四种python实现
- Python的多种风格快速排序案例
- python快速排序
- 快速排序Python实现
- python快速排序
- 快速排序(python)
- python实现快速排序
- postman发送json 请求
- 数据库学习笔记(1):SELECT 各子句的执行顺序
- Linux 死锁检测模块 Lockdep 简介
- 持续交付就得靠容器
- Spring--5.bean管理 依赖注入(xml)
- python的快速排序
- 设计模式之观察者模式
- S32K144 EVB之GPIO
- 初学Python第五天
- Laravel重定向,a链接跳转,控制器跳转
- Mysql的row_format(fixed与dynamic)
- spark-scala版的PageRank
- webAppRootKey
- 如何在Intellij IDEA中修改快捷键