用Java语言实现的各种排序,包括插入排序、冒泡排序、选择排序、Shell排序、快速排序、归并排序、堆排序、SortUtil等。 QRbiO
插入排序: YU! SdT$
Sb@:ercC,
package org.rut.util.algorithm.support; )Zx;Z[
J+oK:tzt8
import org.rut.util.algorithm.SortUtil; Qu4Bd|`(k
/** Fljqh8c5
* @author treeroot O3,IR1
* @since 2006-2-2 4LY
kK/:
* @version 1.0 V2-fJ!
*/ + ;u<tA
public class InsertSort implements SortUtil.Sort{ {OHaI ;
8%-+@\=
/* (non-Javadoc) .Y!]{c
* @see org.rut.util.algorithm.SortUtil.Sort#sort(int[]) $-4OveS~B
*/ aKi&2>c5>
public void sort(int[] data) { *fs'%"w-
int temp; r)S tp`p
for(int i=1;i for(int j=i;(j>0)%26amp;%26amp;(data[j] SortUtil.swap(data,j,j-1); a "*DJ&