02 2014 档案

面试准备 - 最大堆的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) 编辑

面试准备 - C# 版本的树状数组
摘要:树状数组 计算 任意连续N个值的和的时间复杂度为Log(n) 修改也是Log(n)而普通数组修改是O(1) 计算和是O(n)具体定义可以看这里:http://zh.wikipedia.org/zh-cn/%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84或者看这个Blog:http://dongxicheng.org/structure/binary_indexed_tree/这东西刚刚好可以解决 编程之美里面的 1.7光影切割问题using System;using System.Collections.Generic;using System.Linq;using S 阅读全文

posted @ 2014-02-01 19:41 听说读写 阅读(597) 评论(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
点击右上角即可分享
微信分享提示