用Java语言实现的各种排序,包括插入排序、冒泡排序、选择排序、Shell排序、快速排序、归并排序、堆排序、SortUtil等。 NX*9nwp^
插入排序:
K{00 V#
4IYC;J2L
package org.rut.util.algorithm.support; K!9rH>`\
dsxaxbVj%
import org.rut.util.algorithm.SortUtil; d4P0f'.z
/** 5}4MXI4
* @author treeroot %KmB>9
* @since 2006-2-2 _(\\>'1q!
* @version 1.0 ].2it{gF?b
*/ \'L6m1UZ%
public class InsertSort implements SortUtil.Sort{ D{,B[5
" lf_`4
/* (non-Javadoc) =`X;fz
* @see org.rut.util.algorithm.SortUtil.Sort#sort(int[]) )LYj,do
*/ AOaf ,ZF
8
public void sort(int[] data) { N>Pufr
int temp; \g}FoN&