卷珠帘春晚唱了元宵又唱# TVChinese - 中文电视
c*y
1 楼
根据这个link:
http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor#Range_Minimum_Query_%28RMQ%29
LCA的最优解似乎还是O(N) in both time and space complexity
似乎basic idea is transform a tree to an array in Euler Tour, then conduct
RMQ between this range.
如果这样,假设找node1&node2的LCA, 为啥不求得root-node1 & root-node2 path, 然
后找他们的最深交集呢? 难道是因为如果pre-build RMQ,可以support任意两点之间的
LCA?
谢谢讨论, thanks.
http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor#Range_Minimum_Query_%28RMQ%29
LCA的最优解似乎还是O(N) in both time and space complexity
似乎basic idea is transform a tree to an array in Euler Tour, then conduct
RMQ between this range.
如果这样,假设找node1&node2的LCA, 为啥不求得root-node1 & root-node2 path, 然
后找他们的最深交集呢? 难道是因为如果pre-build RMQ,可以support任意两点之间的
LCA?
谢谢讨论, thanks.