Redian新闻
>
真慫阿, Facebook 1st phone interview,
avatar
真慫阿, Facebook 1st phone interview,# JobHunting - 待字闺中
u*l
1
问了一个问题,
里面有用到排序的复杂度。
我知道是 nlogn, 居然鬼使神差的一直用logn.....
一紧张就出错阿。
avatar
r*o
2
啥问题啊。

【在 u*l 的大作中提到】
: 问了一个问题,
: 里面有用到排序的复杂度。
: 我知道是 nlogn, 居然鬼使神差的一直用logn.....
: 一紧张就出错阿。

avatar
u*l
3
很简单,一串数,找前k个最小的。

【在 r****o 的大作中提到】
: 啥问题啊。
avatar
w*1
5
谢谢楼上的链接
avatar
l*a
6
I am confused of the explaination
=============================================
Direct application of the quick sort based selection algorithm
The quick sort based selection algorithm can be used to find k smallest or
k largest elements. To find k smallest elements find the kth smallest
element using the median of medians quick sort based algorithm. After the
partition that finds the kth smallest element, all the elements smaller
than the kth smaller element will be present left to the kth eleme

【在 x****r 的大作中提到】
: 这个题可以O(n)做,见http://en.wikipedia.org/wiki/Selection_algorithm
avatar
y*i
7
这个不是CLRS上的例题么

【在 u*l 的大作中提到】
: 很简单,一串数,找前k个最小的。
avatar
d*e
8
它这里是说,如果用一个random的pivot,worse case可能是O(n^2),
而用median of median找到一个好的pivot,需要O(n),再应用Select找
k-th element,这里主要是花在partition上面,也是O(n),worse case
也是O(n),那么 (k-1) smallest/largest elements就在k-th的左/右边.

【在 l*****a 的大作中提到】
: I am confused of the explaination
: =============================================
: Direct application of the quick sort based selection algorithm
: The quick sort based selection algorithm can be used to find k smallest or
: k largest elements. To find k smallest elements find the kth smallest
: element using the median of medians quick sort based algorithm. After the
: partition that finds the kth smallest element, all the elements smaller
: than the kth smaller element will be present left to the kth eleme

avatar
k*e
9
linear selection
CLRS里面的

【在 u*l 的大作中提到】
: 很简单,一串数,找前k个最小的。
avatar
q*u
10
你这个id太牛了。
鬼使神差这个,就恰好会在那种紧张的时候冒出来

问了一个问题,
里面有用到排序的复杂度。
我知道是 nlogn, 居然鬼使神差的一直用logn.....
一紧张就出错阿。

【在 u*l 的大作中提到】
: 问了一个问题,
: 里面有用到排序的复杂度。
: 我知道是 nlogn, 居然鬼使神差的一直用logn.....
: 一紧张就出错阿。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。