插入排序 (Insert Sort)
来源:互联网 发布:北京师范学校网络教育 编辑:程序博客网 时间:2024/06/10 15:03
Wiki : http://en.wikipedia.org/wiki/Insertion_sort
看看下面的动态图片, 就明白插入排序是怎么回事了:
WiKi上给出的伪代码:
Pseudocode of the complete algorithm follows, where the arrays arezero-based:
// The values in A[i] are checked in-order, starting at the second one for i ← 1 to i ← length(A)-1 { // at the start of the iteration, A[0..i-1] are in sorted order // this iteration will insert A[i] into that sorted order // save A[i], the value that will be inserted into the array on this iteration valueToInsert ← A[i] // now mark position i as the hole; A[i]=A[holePos] is now empty holePos ← i // keep moving the hole down until the valueToInsert is larger than // what's just below the hole or the hole has reached the beginning of the array while holePos > 0 and valueToInsert < A[holePos - 1] { //value to insert doesn't belong where the hole currently is, so shift A[holePos] ← A[holePos - 1] //shift the larger value up holePos ← holePos - 1 //move the hole position down } // hole is in the right position, so put valueToInsert into the hole A[holePos] ← valueToInsert // A[0..i] are now in sorted order }
- 插入排序 (Insert Sort)
- 插入排序(insert sort)
- 插入排序(insert sort)
- 插入排序(Insert Sort)
- 插入排序(Insert-Sort)
- 插入排序(Insert Sort)
- 插入排序-Insert Sort
- 插入排序(insert sort)
- 折半插入排序(Binary Insert Sort)
- Thinking in Insert Sort(插入排序)
- 算法----插入排序(insert sort)
- [排序] 插入排序(Insert Sort)
- (直接)插入排序(Insert Sort)
- 经典排序算法 INSERT-SORT: 插入排序
- recursion-insert-sort( 插入排序的递归实现 )
- 直接插入排序(Straight Insert Sort)
- 【算法】插入排序 insert sort algorithm
- Insert Sort & Shell Sort(插入排序和希尔排序)
- vb.net CPU & RAM 显示程序
- DirectX 3D_实践之在DirectX3D中实现摄像机方位的动态变换
- CentOS下安装Oracle 10g--上
- 两种常见排序算法
- CRM2011资源管理器
- 插入排序 (Insert Sort)
- 重新想象 Windows 8 Store Apps (34)
- 424 - Integer Inquiry
- 好的软件人员必看的60本书
- 通过Web用户控件实现注册(用委托方法)
- 2009年以来我买过的书(部分)
- uva 10635 - Prince and Princess
- javascript常见问题总结转载
- Android开发_ViewPager制作欢迎界面