Time complexity 该程序的时间复杂度
我研究了如何计算程序的时间复杂度。但我能理解的只是命令。我的意思是我只能区分n^3,n^2,log(n),n,或1中的大O。但我永远无法理解O(V+E)或O(N*M)的意思。我同意我的基本原则是不够的。这就是我想了解它的原因。请提供我一些链接或网站,如果你不能在这里解释 还有一件事,有人能给我一个基本的想法,如何找到这个程序的时间复杂性吗Time complexity 该程序的时间复杂度,time-complexity,Time Complexity,我研究了如何计算程序的时间复杂度。但我能理解的只是命令。我的意思是我只能区分n^3,n^2,log(n),n,或1中的大O。但我永远无法理解O(V+E)或O(N*M)的意思。我同意我的基本原则是不够的。这就是我想了解它的原因。请提供我一些链接或网站,如果你不能在这里解释 还有一件事,有人能给我一个基本的想法,如何找到这个程序的时间复杂性吗 [nRow, nCol, noOfRotation] = [int(x) for x in input().split()] matrix = [ [0 f
[nRow, nCol, noOfRotation] = [int(x) for x in input().split()]
matrix = [ [0 for j in range(nCol)] for i in range(nRow) ]
for i in range(nRow):
matrix[i] = [int(x) for x in input().split()]
maxRow = nRow-1
maxCol = nCol-1
start = 0
while start < maxRow and start < maxCol:
tempMat = []
for col in range(start, maxCol):
tempMat.append( matrix[ start ][ col ] )
for row in range(start, maxRow):
tempMat.append( matrix[ row ][ maxCol ] )
for col in range(maxCol, start, -1):
tempMat.append( matrix[ maxRow ][ col ] )
for row in range(maxRow, start, -1):
tempMat.append( matrix[ row ][ start ] )
length = len(tempMat)
i = 0
for col in range(start, maxCol):
matrix[ start ][ col ] = tempMat[ (i + noOfRotation) % length ]
i += 1
for row in range(start, maxRow):
matrix[ row ][ maxCol ] = tempMat[ (i + noOfRotation) % length ]
i += 1
for col in range(maxCol, start, -1):
matrix[ maxRow ][ col ] = tempMat[ (i + noOfRotation) % length ]
i += 1
for row in range(maxRow, start, -1):
matrix[ row ][ start ] = tempMat[ (i + noOfRotation) % length ]
i += 1
start += 1
maxRow -= 1
maxCol -= 1
for i in range(nRow):
for j in range(nCol):
print(matrix[i][j], end = ' ')
print('')
[nRow,nCol,noOfRotation]=[int(x)表示输入中的x().split()]
矩阵=[[0表示范围内的j(nCol)]表示范围内的i(nRow)]
对于范围内的i(nRow):
矩阵[i]=[int(x)表示输入中的x().split()]
maxRow=nRow-1
maxCol=nCol-1
开始=0
启动
问题链接:当一个算法有多个输入,每个输入都有独立的大小,或者输入有多个“大小”度量,例如矩阵的宽度和高度时,使用O(N*M)等符号;N和M只是测量这些独立尺寸的不同变量。类似地,O(V+E)通常出现在图算法中,其中V表示图中的顶点数,E表示图中的边数。@kaya3是的,我明白了。你能帮我找出上面代码的时间复杂度吗?