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

标签 c# .net time-complexity

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/

相关文章:

c# - 如何提取子字符串并将其替换为不同的值

c# - List<string> 对象 IndexOf 返回 -1。如何?

c# - 拥有一个带有 C++ 类的 DLL,即构造函数接受其他 C++ 类,如何使 C# 能够创建其实例?

arrays - 获取一组字符串对并返回所有连接项的数组

algorithm - 为什么执行 n union find (union by size) 操作的时间复杂度是 O(n log n)?

c# - NDesk.选项 : how to register required parameters correctly?

c# - 具有 XAML 中定义的选项的数据绑定(bind) WPF ComboBox?

c# - XmlSerializer 和类和 xml 属性中的不同字段

Java 和 .NET 互操作 (RSA) 签名

c++ - 如何将这些自定义对象列表的时间复杂度从 O(n) 降低到 O(1)?