Algorithm to find lowest common ancestor in directed acyclic graph?

后端 未结 10 927
孤独总比滥情好
孤独总比滥情好 2020-12-02 11:34

Imagine a directed acyclic graph as follows, where:

  • \"A\" is the root (there is always exactly one root)
  • each node knows its parent(s)
  • the no
10条回答
  •  误落风尘
    2020-12-02 12:09

    I also need exactly same thing , to find LCA in a DAG (directed acyclic graph). LCA problem is related to RMQ (Range Minimum Query Problem).

    It is possible to reduce LCA to RMQ and find desired LCA of two arbitrary node from a directed acyclic graph.

    I found THIS TUTORIAL detail and good. I am also planing to implement this.

提交回复
热议问题