加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 03:59:46 所属栏目:百科 来源:网络整理
导读:什么是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 p
什么是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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读