c# – .NET List.sort()的时间复杂度是多少?

前端之家收集整理的这篇文章主要介绍了c# – .NET List.sort()的时间复杂度是多少?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
什么是C#的List< T> .Sort()的时间复杂度

我想是(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.

原文链接:https://www.f2er.com/csharp/93063.html

猜你在找的C#相关文章