【问题标题】:Complexity for finding if a relation is symmetric?查找关系是否对称的复杂性?
【发布时间】:2014-05-14 17:16:10
【问题描述】:

我有一个问题说

Let a directed graph G model a relation R. If G is represented using adjacency lists, then,
the worst case time complexity for finding whether R is symmetric would be (as a
function of |R| ) _____?

根据我的答案,要查找是否满足对称属性,我们只需要访问两个顶点并检查它们是否都在彼此的邻接列表中。 所以,最坏的情况是 O(degree(vertex)) 但给出的答案是 O(|R|*|R|) 或 O(|E|*|E|)

如何?

【问题讨论】:

    标签: data-structures graph complexity-theory relation


    【解决方案1】:

    O(度(顶点))是什么意思?

    除此之外,还必须考虑必须检查相关的每一对是否有反向。所以对于每对|R|关系成员,将进行搜索。搜索本身——如果不使用任何技巧的话——是关于访问 |R| pair ,所以在最坏的情况下它会是 |R|*|R|

    【讨论】:

    • 按 O(degree(vertex)),我的意思是 O(degree of vertex)..无论如何你的解决方案证明了答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-29
    • 1970-01-01
    相关资源
    最近更新 更多