python 写的归并排序
来源:互联网 发布:钢板承载力计算软件 编辑:程序博客网 时间:2024/04/29 05:17
需要补充点基础理论姿势了。
def megraSort(sortArray1, sortArray2): retList = [] i = j = 0 while i < len(sortArray1) and j < len(sortArray2): if sortArray1[i] <= sortArray2[j]: retList.append(sortArray1[i]) i += 1 else: retList.append(sortArray2[j]) j += 1 while i < len(sortArray1): retList.append(sortArray1[i]) i += 1 while j < len(sortArray2): retList.append(sortArray2[j]) j += 1 return retListdef sort(sortArray1): #如果是数组,继续划分 print sortArray1 length = len(sortArray1) if length == 1: return sortArray1 else: sa1 = sort(sortArray1[0 : length / 2]) sa2 = sort(sortArray1[length / 2 : length]) print 'sort ' , sa1, sa2 return megraSort(sa1, sa2)
- python 写的归并排序
- python写希尔、堆、快速、归并排序
- 归并排序的Python实现
- 归并排序的Python实现
- 自写的万能归并排序
- 自己写的归并排序(源码)
- 借鉴一下别人写的归并排序
- 自己写的一个归并排序
- 同事写的二分归并排序
- 我自己写的归并排序。。
- [排序] 归并排序(Python)
- 【动手写排序】归并排序
- 归并排序算法的python实现
- 改进版python实现的归并排序
- 快速排序、堆排序、归并排序的python实现
- 归并排序 with Python
- python 归并排序
- python中的归并排序
- qt4移植到qt5注意点
- c++ (持有对方引用)设计模式
- Java Map遍历方式的选择
- 项目预估激发的矛盾
- spring mvc的获取参数和传递参数
- python 写的归并排序
- "Introduction to the Theory of Computation" Reading notes - Ch. 0 and 1
- 电容,电阻的误差值
- UIPickerView内容居中显示,设置初始默认值
- container_of
- 电子签名的早期应用与未来趋势
- Android将Activity打成jar包供第三方调用(解决资源文件不能打包的问题)
- PHPExcel分析
- Epoll and 介绍Sniff网络嗅探器代码