是否有可能来计算数字列表更好的中位数比为O(n log n)的? [英] Is it possible to calculate median of a list of numbers better than O(n log n)?

查看:112
本文介绍了是否有可能来计算数字列表更好的中位数比为O(n log n)的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,这是可以计算的数字在O(n)的一个列表的平均值。但是,我们的中位数?有没有什么比排序更好的算法(为O(n log n)的)和查找中量元素(或平均两个中间元素,如果是偶数在列表中的项目)?

I know that it is possible to calculate the mean of a list of numbers in O(n). But what about the median? Is there any better algorithm than sort (O(n log n)) and lookup middle element (or mean of two middle elements if an even number of items in list)?

推荐答案

是的。您可以为O(n)这样做(确定性)。

这篇关于是否有可能来计算数字列表更好的中位数比为O(n log n)的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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