从方阵中获取对称元素的复杂性是多少?

时间:2016-04-20 16:14:54

标签: python matrix time-complexity

我想获得对称元素的位置(一对索引package main import ( "container/list" "fmt" ) func main() { // Create a new list and put some numbers in it. l := list.New() e4 := l.PushBack("4") e1 := l.PushFront("1") l.InsertBefore("3", e4) l.InsertAfter("2", e1) // Iterate through list and print its contents. for e := l.Front(); e != nil; e = e.Next() { fmt.Println(e.Value) } } )( (i, j) i≠j )来自方形布尔矩阵 A 。这是我的代码。

Aij=Aji

假设 A 是一个大小为 n 的方阵。平均需要import numpy as np A = np.matrix([ [0, 0, 0], [1, 0, 1], [1, 1, 0]]) for (i, j), value in np.ndenumerate(A): if i>j and A[i,j] == A[j,i]: print(i,j) # output: (2, 1) break 步才能得到这样一个元素,因此时间的复杂度是 o(n ^ 2),对吗?

如果 A 稀疏布尔矩阵,是否有更有效的解决方案?

0 个答案:

没有答案