时间是什么.NET List.sort的复杂性() [英] What is time complexity of .NET List.sort()

查看:134
本文介绍了时间是什么.NET List.sort的复杂性()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是时间的C#的复杂性名单,其中,T> .Sort()

What is time complexity of C#'s List<T>.Sort()

我想这是O(N)

但之后我搜索了很多,我没有得到任何准确的结果。

But after I searched a lot, I didn't get any accurate result.

推荐答案

<一个href="http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspx">http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspx

此方法使用的Array.Sort,它采用了快速排序算法。此实现执行不稳定排序;也就是说,如果两个元素是相等的,它们的顺序可能不是preserved。与此相反,一个稳定的排序preserves中等于元素的顺序

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.

在平均,这种方法是为O(n log n)的操作,其中n是计数;在最坏的情况下,它是一个为O​​(n ^ 2)操作

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.

这篇关于时间是什么.NET List.sort的复杂性()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆