Graphs: find a sink in less than O(|V|) - or show it can't be done

前端 未结 7 1137
死守一世寂寞
死守一世寂寞 2021-02-01 10:17

I have a graph with n nodes as an adjacency matrix.

Is it possible to detect a sink in less than O(n) time?

If yes, how? If no

7条回答
  •  没有蜡笔的小新
    2021-02-01 10:20

    Reading the link provided by SPWorley I was reminded of tournament tree algo for finding the minimum element in an array of numbers. The node at the top of the tree is a minimum element. Since the algorithm in the link also speaks about competition between two nodes (v,w) which is succeeded by w if v->w otherwise by v. We can use an algorithm similar to finding minimum element to find out a sink. However, a node is returned irrespective of the existence of a sink. Though, if a sink exists it is always returned. Hence, we finally have to check that the returned node is a sink.

    //pseudo code
    //M -> adjacency matrix
    int a=0
    for(int i=1;i

提交回复
热议问题