Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将矩阵初始化为所有 0 值。复杂度是 O(1) 还是 O(n)?
事实上,如果初始化复杂度是一个问题,并且进一步的矩阵访问是有序的,你可以:
这种方法在矩阵初始化中可能不会比在进一步处理中更复杂。
这取决于它的含义N
N
O(N^2)
N = R*C
R
C
O(N)