摘要: 这一题就是要求一组数据的中位数。思路有几种:1、快排。再找出中间的数就行了,但是复杂度为nlog(n);2、利用求中位数的最优算法是O(N)的Select算法。但是我怀疑这个算法的复杂度应该不是O(N)的。下面就我自己的思路来理解一下select算法。先贴一下代码:#include <iostream>#include <cstdio>#include <algorithm>#include <iterator>using namespace std;int a[10001];int find_min_N(int s,int e,int n){ 阅读全文
posted @ 2012-07-24 15:12 HNU_AlienForce 阅读(157) 评论(0) 推荐(0)