小编MEH*_*UDI的帖子

如何提高算法时间复杂度?

我们有“ n”个文件,对于每个文件“ m”行,我们要进行一些操作,以处理所有文件和行,显然可以应用以下算法:

int n;    //n is the number of files 
int m;   //m is the number of the lines in the file i.
for(i=0;i<n;i++){
   for(j=0;j<m;j++){
            .....
   }
}
Run Code Online (Sandbox Code Playgroud)

因此,我们有一个O(nxm)复杂度。

我的问题是:

是否可以通过以下方式使其变为O(nlog(n))或其他方法来提高算法的时间复杂度:

1-保留所有文件和行。

2-我们可以忽略其中的一些。

最好的祝福

algorithm time-complexity

0
推荐指数
1
解决办法
78
查看次数

标签 统计

algorithm ×1

time-complexity ×1