什么是C#的List< T> .Sort()的时间复杂度
我想是(N)
但是,当我搜索很多,我没有得到任何准确的结果.
解决方法
@L_403_0@
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.