d****o 发帖数: 1055 | 1 Give some scenarios where you might favor O(n^2) algorithm over a O(nlg
(n)) one" |
p*****2 发帖数: 21240 | 2
same space complexity?
【在 d****o 的大作中提到】 : Give some scenarios where you might favor O(n^2) algorithm over a O(nlg : (n)) one"
|
b******v 发帖数: 1493 | 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"
|
g*********e 发帖数: 14401 | |
K*******i 发帖数: 399 | 5 n比较小的时候的排序?
比如快排递归到n小的时候用插入排序? |
g***s 发帖数: 3811 | 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小的时候用插入排序?
|
s******n 发帖数: 7 | 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 ? |