1
我在R中使用了dist
函数,我想知道它的时间复杂度。dist()的复杂性是什么?
我知道层次聚类的时间复杂度为N^2*logN
。层次聚类由R中的两部分代码组成。
> d <- dist(as.matrix(mtcars)) # find distance matrix
> hc <- hclust(d) # apply hirarchical clustering
> plot(hc) # plot the dendrogram
在应用层次聚类之前,需要计算距离矩阵。我认为这需要N^2
的复杂性?
'hclust'函数应该有O(n³)运行时。 –