相关疑难解决方法(0)

检查数组是否排序的最快方法

考虑到从一个非常大的函数返回的数组.

fastest如果对数组进行排序,测试的方法是什么?

最简单的方法是:

/// <summary>
/// Determines if int array is sorted from 0 -> Max
/// </summary>
public static bool IsSorted(int[] arr)
{
for (int i = 1; i < arr.Length; i++)
{
    if (arr[i - 1] > arr[i])
    {
    return false;
    }
}
return true;
}
Run Code Online (Sandbox Code Playgroud)

.net c# sorting algorithm

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

.net ×1

algorithm ×1

c# ×1

sorting ×1