用Java语言实现的各种排序,包括插入排序、冒泡排序、选择排序、Shell排序、快速排序、归并排序、堆排序、SortUtil等。 ~gW^9nWYU
插入排序: 7L6L{~8
W
K)!^NT
package org.rut.util.algorithm.support; Y1I)w^}:
{4,],0bjx/
import org.rut.util.algorithm.SortUtil; _p%n%Oce
/** d?J&mLQ6
* @author treeroot <{bxOr+
* @since 2006-2-2 qD ?`Yd
* @version 1.0 7+hF1eoI
*/ \>Rfa+
public class InsertSort implements SortUtil.Sort{ j|wN7@Zc
vg[3\!8z[
/* (non-Javadoc) 4F
G0'J&hw
* @see org.rut.util.algorithm.SortUtil.Sort#sort(int[]) znTi_S
*/ ]#^v754X^T
public void sort(int[] data) { S<Gm*$[7
int temp; 4Ex&A