我有这种类型的QuickSort和Test Class.秒表不起作用,总是0ms.
任务是实现指定的算法 - 将程序设计为控制台应用程序.我需要根据源数据的长度来估计算法的执行时间.
快速排序
public static void Sorting(int[] array, int first, int last)
{
int x = array[(last - first) / 2 + first];
int temp;
int i = first;
int j = last;
while (i <= j)
{
while (array[i] < x && i <= last) ++i;
while (array[j] > x && j >= first) --j;
if (i<=j)
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
++i;
--j;
}
}
if (j > first)
{ …Run Code Online (Sandbox Code Playgroud)