C# 的 List<T>.Sort()
的时间复杂度是多少?
我猜是o(N)
但是我找了很多,都没有得到准确的结果。
最佳答案
http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspx
This method uses Array.Sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
On average, this method is an O(n log n) operation, where n is Count; in the worst case it is an O(n ^ 2) operation.
关于c# - .NET List.sort() 的时间复杂度是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9612167/