插入排序 python
来源:互联网 发布:爱站seo 编辑:程序博客网 时间:2024/06/07 03:07
#!/usr/bin/env python
# coding=utf-8
'''
roy(火炎神) 2010/10/10
插入排序 照着<<算法技术手册>>上写的
'''
import random,time
_data = []
_newData = []
size = 15
def createData():
for i in range(size):
_data.append(random.randrange(0,size))
def sort(a):
for i in range(size):
insert(a,i,a[i])
def insert(a,index,value):
i = index - 1
while i>=0 and a[i]>value :
a[i+1] = a[i]
i = i-1
a[i+1] = value
def main():
createData()
print _data
sort(_data)
print _data
if __name__ == "__main__":
main()
- Python--排序--插入排序
- 插入排序 python
- python插入排序算法
- python之插入排序
- python实现插入排序
- python实现插入排序
- python插入排序
- Python 直接插入排序
- Python 折半插入排序
- Python 实现插入排序
- python 插入排序
- Python实现插入排序
- python实现插入排序
- python 插入排序
- python 插入排序
- python插入排序
- python 插入排序
- Python之插入排序
- 1172. Queens, Knights and Pawns
- 每个程序员应该知道12件事
- Linq DataContext and Dispose
- 口语究竟怎么练?
- [JavaScript] In Velocity, CANNOT assign null to LRS
- 插入排序 python
- 基于P2P网络技术应用的思考
- [转]深入了解VC++编译器
- MiniGUI-1.6.10在ARM上的移植
- 完善Library的管理方式
- 架构师之路(7)---里氏代换原则 王泽宾
- H.264将普及 视频编码讲坛之H.264前世今生
- Qtopia/Qt 中文支持
- C# 16进制转换10进制相关函数详解