[algogeeks] Least Common Ancestor in an n ary tree

2011-08-04 Thread ankit sambyal
Find LCA in n ary tree ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] Least Common Ancestor in an n ary tree

2011-08-04 Thread Gaurav Menghani
If there are N nodes and it is an n-ary tree, O(N) pre-processing is required for every node, storing its parent in each step. Subsequently, if LCA(u,v) is to be found, produce the list of ancestors A(u) and A(v), which can be done in O(log-n N) steps. Then compare A(u) and A(v) to find the