Sorting Algorithms ------[Insertion Sort]
来源:互联网 发布:office在哪卸载软件 编辑:程序博客网 时间:2024/06/07 06:59
- public class InsertionSort {
- public static void main(String args[]){
- InsertionSort s=new InsertionSort();
- s.a();
- }
- public void a(){
- int []num={7,5,1,4,6,5,3,9,23,13,57,2,456,434};
- long t=System.currentTimeMillis();
- for(int i=1;i<num.length;i++){
- int key=num[i];
- int j=i-1;
- while(j!=0 && j>=0 && num[j]<key){
- num[j+1]=num[j];
- j=j-1;
- }
- num[j+1]=key;
- }
- long t1=System.currentTimeMillis();
- System.out.println(t+"-----"+t1);
- for(int i=0;i<num.length;i++){
- System.out.print(num[i]+"--");
- }
- }
- }
Insertion Sort :
Moderately for small N
Not At All for large N
- Sorting Algorithms ------[Insertion Sort]
- INSERTION-SORT: INTRODUCTION TO ALGORITHMS
- 【Leetcode】Insertion Sort List (Sorting)
- Sorting Algorithm-Straight Insertion Sort
- introduction to algorithms sorting lesson 1 insertion
- Introduction: Analysis of Algorithms, Insertion Sort, Merge Sort
- Insertion Sorting
- [LeetCode-Algorithms-147] "Insertion Sort List" (2017.12.21-WEEK16)
- Sorting Algorithms
- sorting algorithms
- Sorting Algorithms
- The Program of Algorithms ------- Sorting in Linear Time---- Counting Sort
- The Program of Algorithms ------- Sorting in Linear Time---- Bucket Sort
- introduction to algorithms sorting lesson_6 Counting sort (计数排序)
- 【Data Structures】 7. Simple Sorting—Bubble Sort, Selection Sort, and Insertion Sort
- Insertion Sort
- Insertion Sort
- insertion sort
- INFORMIX-如何利用onpladm进行大数据量表重建
- Log4J使用完全手册(转)
- C# 预处理器指令
- MP3编码原理概述[转]
- 像radiobuton一样可以单选,checkbox单选
- Sorting Algorithms ------[Insertion Sort]
- 21天训练营-----图图的行程----第一个脚印
- SQL join
- 复制GridView单元格内容到剪贴板
- [转贴]HTML标签详解
- Web 设计:实现干净代码的12条定律
- 没有加入域的ISA防火墙客户端如何连接在域中的ISA
- (转)Socket 编程 通俗易懂,全面
- 【资源】SCJP 310-055备考资料