2014年2月21日

面试准备 - 最大堆的Csharp实现

摘要: 面试中最常见的问题之一。。。在N个数中间寻找前K大个元素最常见的解法就是最大堆 时间复杂度O(N*log(K)) 空间复杂度O(k)实现了一个最简单的最大堆,每次有元素进来都和堆顶元素比较一下,如果新元素比较大就替换,然后就逐级更新到堆底namespace Clover.Algoritms.DataStructure{ using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reflection; using System.Runtime.Comp... 阅读全文

posted @ 2014-02-21 08:27 听说读写 阅读(2103) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示