Sort Algorithm-->Select Sort
2016-07-24 23:38
537 查看
Each traversal find the minimal element start from 1 to n,than compare with the index of i,i+1…n-1,if smaller than swap them or next traversal
""" select sort language:python3.5 author:zhoutonglx """ #original unsorted list L = [3,44,38,5,47,15,36,26,27,2,46,4,19,50,48] def SelectSort(L): length = len(L) for i in range(length-1) : for j in range(i+1,length) : if L[i]>L[j] : L[i],L[j] = L[j],L[i] # like swap() in c++ print(L) if __name__ == "__main__" : SelectSort(L)
相关文章推荐
- 2.go开源groupcache项目——关于protobuf
- go中方法的接收者是值或者指针的区别
- Django集成的子框架
- Sort Algorithm-->Bubble Sort
- Google首席工程师Joshua Bloch谈如何设计优秀的API
- Algorithms for Detecting Significantly Mutated Pathways in Cancer
- Google推荐的图片加载库Glide介绍
- 使用google的zxing类生成一维码、二维码实例
- ”The virtual device got no IP address.“的解决
- hdu 5190 Go to movies(水)
- Django中CSRF实现分析
- 维特比算法(Viterbi Algorithm)
- 前向算法(Forward Algorithm)
- golang的参数验证
- django 静态文件路径设置
- MyBatis Generator 详解(good)
- hiho108周即题库1198Memory Allocating Algorithm
- 卡方检验(Chi-square test/Chi-Square Goodness-of-Fit Test)
- Django博客开发(十三)—一个简单的站内搜索
- L11,one good turn deserves another