码迷,mamicode.com
首页 >  
搜索关键字:insertsort    ( 209个结果
20140829 直接插入排序
#include void InsertSort(int a[],int len) { int temp=0,i,j; for(i=1;i=0&&temp<a[j];j--) { a[j+1]=a[j]; } a[j+1]=temp; } } Pint main() { int a[]...
分类:其他好文   时间:2014-09-01 12:03:13    阅读次数:248
插入排序
插入排序就简单了,类似于打扑克,我们搬到的牌会把它插入到之前已经拍好序的牌堆中,过程如下: 代码直接上: void insertSort(int a[],int length){ for(int j = 1;j = 0 && a[i] > key){ a[i+...
分类:其他好文   时间:2014-08-28 22:46:46    阅读次数:322
排序算法
最近忙着复习找工作,熟悉了下排序算法,动手写了一下,发现有些问题的边界条件还是没有考虑清楚,不过好在调试成功。不稳定排序:堆排序,快速排序,希尔排序;稳定排序:插入排序,冒泡排序,选择排序,归并排序,基数排序等。插入排序算法代码:void InsertSort(int A[],int n){ ...
分类:其他好文   时间:2014-08-28 19:39:25    阅读次数:287
直接插入排序
先上代码。/**** @author:hushunfeng** 直接插入排序 从小到大进行排列*/#includevoid insertSort(int *array,int arraySize) { //用于缓存被插入数 int temp; int i; in...
分类:其他好文   时间:2014-08-05 18:32:49    阅读次数:172
插入排序
#includevoid InsertSort(int n,int a[]){ int j; for(int i=0;i=0;j--) { if(a[j]>tmp) { a[j+1]=a[j]; ...
分类:其他好文   时间:2014-07-26 14:02:05    阅读次数:171
[转] 插入排序
一、直接插入排序算法:void insertSort(int* data, int len){ int sentry;//哨兵 int i,j; for(i = 1; i 1)趟排序时,前(i-1)个记录已经有序,于是查找插入位置我们可以用折半查找。算法如下: 1 void bI...
分类:其他好文   时间:2014-07-26 00:41:36    阅读次数:284
直接插入排序、二分插入排序、希尔排序、冒泡排序与简单选择排序
一、直接插入排序 稳定,时间复杂度:最好O(n)、最差O(n^2)、平均O(n^2),空间复杂度O(1) void InsertSort(int L[], int n) { int i, j,key; for (i = 1; i<n; i++) if(L[i] < L[i-1])//需要将L[i]插入到有序表L[0...i-1] { key = L[i];...
分类:其他好文   时间:2014-07-08 13:40:33    阅读次数:137
插入排序
import java.util.*;public class InsertionSort { /* * 升序排列 * * */ public static void insertSort(int[] input) { for (int i...
分类:其他好文   时间:2014-06-26 16:04:32    阅读次数:190
数据结构--内排序
直接插入排序#include typedef int Keytype;typedef struct{ Keytype key; int data;}RecType;void InsertSort(RecType R[],int n){ int i; int j; RecType temp; f...
分类:其他好文   时间:2014-06-21 09:52:18    阅读次数:223
常见排序算法(PHP实现)
function InsertSort($arr){ $num = count($arr); for($i = 1; $i = 0; $j--){ if($arr[$j] > $key){ $arr[$j + 1...
分类:Web程序   时间:2014-06-12 16:51:05    阅读次数:270
209条   上一页 1 ... 18 19 20 21 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!