avatar
G 家的题目 讨论# JobHunting - 待字闺中
d*o
1
Give some scenarios where you might favor O(n^2) algorithm over a O(nlg
(n)) one"
avatar
p*2
2

same space complexity?

【在 d****o 的大作中提到】
: Give some scenarios where you might favor O(n^2) algorithm over a O(nlg
: (n)) one"

avatar
b*v
3
O(n^2)实现简单(不易出错)而且够快
就没必要用实现复杂的O(n logn)

【在 d****o 的大作中提到】
: Give some scenarios where you might favor O(n^2) algorithm over a O(nlg
: (n)) one"

avatar
g*e
4
比如n=10,100,1000的时候
avatar
K*i
5
n比较小的时候的排序?
比如快排递归到n小的时候用插入排序?
avatar
g*s
6
yes. that's what i used when there was no sort api
for i = 1 to n-1
for j = i+1 to n
if (a[i] > a[j]){
x=a[i];a[i]=a[j];a[j]=x;
}


【在 K*******i 的大作中提到】
: n比较小的时候的排序?
: 比如快排递归到n小的时候用插入排序?

avatar
s*n
7
Just a guess: suppose O(n^2) = C_1*n^2 and O(nlog(n)) = C_2*nlog(n) then for
n such that C_1*n^2 < C_2*nlog(n) ,i.e. when n/log(n) < C_2/C_1 we prefer
the former ?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。