⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsort.java

📁 The running time of quicksort can be improved in practice by taking advantage of the fast running t
💻 JAVA
字号:
public class TestSort
{
	public static void main(String[] args) 
	{
		//Create 2 same arrays with 5 numbers at random.
		double[] sourceArrayForInsertionSort = new double[5];
		double[] sourceArrayForQuickSort = new double[5];
		for (int n = 0; n < sourceArrayForInsertionSort.length; n ++)
				sourceArrayForInsertionSort[n] = Math.random();
		for (int n = 0; n < sourceArrayForQuickSort.length; n ++)
				sourceArrayForQuickSort[n] = sourceArrayForInsertionSort[n];

		//Insertion sort.
		Sort insertionSort = new Sort(sourceArrayForInsertionSort);
		insertionSort.insertionSort(0, sourceArrayForInsertionSort.length - 1);
		System.out.println("The result of insertion sort is:");
		insertionSort.result();
		System.out.println("");

		//Quick sort
		Sort quickSort = new Sort(sourceArrayForQuickSort);
		quickSort.quickSort(0, sourceArrayForQuickSort.length - 1);
		System.out.println("The result of quick sort is:");
		quickSort.result();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -