-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xulw
committed
Jul 21, 2018
1 parent
fe91244
commit 5eb4963
Showing
7 changed files
with
215 additions
and
42 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,39 @@ | ||
package algorithm; | ||
|
||
import java.util.Arrays; | ||
|
||
public class AlgoTest { | ||
|
||
public static final int N = 2000; | ||
public static final int N = 50000; | ||
public static final int RANGE_R = 20; | ||
public static final int RANGE_L = 400; | ||
public static final int MAX_OF_STUDENT_NUM = 2000; | ||
|
||
public static final String AFTER_TEXT = "\n after : "; | ||
public static final String CLASS_NAME = "algorithm.Sort"; | ||
|
||
public static void testSelectionSort() { | ||
Integer[] arr = new Integer[N]; | ||
arr = SortTestHelper.generateRandomArray(N, RANGE_R, RANGE_L); | ||
SortTestHelper.printArray(arr); | ||
System.out.println(AFTER_TEXT); | ||
Sort.selectSort(arr); | ||
SortTestHelper.printArray(arr); | ||
public AlgoTest() { | ||
// Integer[] arr = SortTestHelper.generateNearlyOrderedArray(N, 100); | ||
Integer[] arr = SortTestHelper.generateRandomArray(N, 0, 400); | ||
handleSort(Sort.INSERT_SORT, arr.clone()); | ||
handleSort(Sort.INSERT_SORT_AD, arr.clone()); | ||
handleSort(Sort.BUBBLE_SORT, arr.clone()); | ||
// handleSort(Sort.BUBBLE_SORT_AD_V1, arr.clone()); | ||
// handleSort(Sort.BUBBLE_SORT_AD_V3, arr.clone()); | ||
handleSort(Sort.MERGE_SORT, arr.clone()); | ||
handleSort(Sort.SELECT_SORT, arr.clone()); | ||
} | ||
|
||
public static void testBubbleSort() { | ||
Integer[] arr = new Integer[N]; | ||
arr = SortTestHelper.generateRandomArray(N, RANGE_R, RANGE_L); | ||
SortTestHelper.printArray(arr); | ||
Sort.bubbleSort(arr); | ||
SortTestHelper.printArray(arr); | ||
private static <T extends Comparable> void handleSort(String sortName, T[] arr) { | ||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
SortTestHelper.testSort(sortName, CLASS_NAME, arr); | ||
} | ||
}).start(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
// testSelectionSort(); | ||
// Student[] ss = Student.generateStudentArray(N, MAX_OF_STUDENT_NUM); | ||
// Integer[] arr = SortTestHelper.generateRandomArray(N, RANGE_R, RANGE_L); | ||
// Sort.insertSort(arr); | ||
// SortTestHelper.printArray(arr); | ||
// System.out.println(SortTestHelper.isSorted(arr)); | ||
// | ||
// | ||
testBubbleSort(); | ||
new AlgoTest(); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters