直接插入排序(Straight Insertion Sort)代码及分析注释
来源:互联网 发布:淘宝消费总金额怎么看 编辑:程序博客网 时间:2024/05/29 18:59
class StraightInsertionSort {// 直接插入排序 public static int[] SISort(int[] array) { for (int round = 1; round < array.length; round++)// 控制比较的趟数、指针的起点:从前向后依次插入 { if (array[round] < array[round - 1]) {// 当待插入数小于前一个数才开始排序,如果大于(或等于)则直接插入了 int index = round;// 记录待插入位置的索引 int tmp = array[round];// 记录需要插入的元素的值 for (; index > 0 && tmp < array[index - 1]; index--) {// 从指针起点index依次向前(index--)比较,直到与array[0]比较(index>0),当待插入数tmp小于前一个数时,则执行... array[index] = array[index - 1];// 将前一个数向后挪一位 } // 当比较完array[0]或待插入值tmp大于前一个数时,将待插入数插入指针位置 array[index] = tmp; } } return array; }}
0 0
- 直接插入排序(Straight Insertion Sort)代码及分析注释
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 排序之直接插入排序(Straight Insertion Sort)
- 排序(三)之直接插入排序Straight Insertion Sort
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 数据结构 - 直接插入排序(Straight Insertion Sort) 详解 及 代码(C++)
- 直接插入排序算法(Straight Insertion Sort) Java实现
- 1.插入排序—直接插入排序(Straight Insertion Sort)
- 插入排序—直接插入排序(Straight Insertion Sort)
- 八大排序算法_直接插入排序(Straight Insertion Sort)
- 排序算法之 直接插入排序算法(Straight Insertion Sort):(Python)
- PHP实现排序算法----直接插入排序(Straight Insertion Sort)
- PHP实现排序算法----直接插入排序(Straight Insertion Sort)
- 冒泡排序(bubble sort)、直接插入排序(straight insertion sort)、简单选择排序(simple selection sort)
- iOS图片拉伸技巧—— resizableImageWithCapInsets
- JavaScript prototype 属性
- JButton点击事件获取另一个JPanel中JTextField文本
- 如何在Eclipse中利用pydev调试Django
- Unix学习笔记------文件IO------使用lseek设置文件当前读写偏移量(即:当前的读写位置)
- 直接插入排序(Straight Insertion Sort)代码及分析注释
- 编程之美-程序理解和时间分析整理
- muduo库阅读(11)——文件工具类
- When to use Delegation, Notification, or Observation in iOS
- Poj 3463 Sightseeing
- 数据库 数据丢失问题 及解决方案
- 如何安装Aptana
- 内核3.x版本之后设备树(device tree)机制
- Laplacian of Gaussian (LoG)