摘要:
View Code 1 import java.util.Random; 2 3 public class MergeSort { 4 private double[] bridge;//辅助数组 5 6 public void sort(double[] obj){ 7 if (obj == null){ 8 throw new NullPointerException("The param can not be null!"); 9 }10 bridge = new double[... 阅读全文
摘要:
View Code 1 public class MySelectionSort { 2 3 // 直接选择排序 4 public void StraightSelectionSort(double[] sorted) { 5 for (int i = 1; i < sorted.length; i++) { 6 int minIndex = findMinIndex(sorted, i); 7 exchange(sorted, i, minIndex); 8 } 9 }10 11 ... 阅读全文
摘要:
View Code 1 public class MyExchangeSort { 2 // 冒泡排序 3 public void BubbleExchangeSort(double[] sorted) { 4 for (int i = 1; i < sorted.length; i++) {//进行排序次数为数组长度-1 5 for (int j = 0; j < sorted.length - i; j++) {//从上到下进行排序,大数下沉 6 if (sorted[j] > sorted[j + ... 阅读全文
摘要:
View Code 1 //升序 2 public class MyInsertSort { 3 // 直接插入排序 4 public void StraightInsertionSort(double[] sorted) { 5 int i, j; 6 for (i = 2; i < sorted.length; i++) { 7 if (sorted[i] < sorted[i - 1]) { 8 sorted[0] = sorted[i];// 设一监视哨 9 ... 阅读全文