Re: [algogeeks] Least Common Ancestor in STL MAP

2013-03-22 Thread Shashwat Anand
On 3/21/13 5:02 PM, Avinash wrote: Given a STL map, say mapint, bool m1. Given two value a b that may or may not exists in m1. Find the Least Common Ancestor in STL MAP. Remember you don't have access to root, so you need to iterate using iterator. Use the methods/function of MAP forex begin,

[algogeeks] Least Common Ancestor in STL MAP

2013-03-21 Thread Avinash
Given a STL map, say mapint, bool m1. Given two value a b that may or may not exists in m1. Find the Least Common Ancestor in STL MAP. Remember you don't have access to root, so you need to iterate using iterator. Use the methods/function of MAP forex begin, end, find etc. Solution should be

[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

Re: [algogeeks] Least Common Ancestor

2011-07-28 Thread kavitha nk
http://geeksforgeeks.org/?p=1029 follow the link fa one more soln.. //BE COOL// kavi -- 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

Re: [algogeeks] Least Common Ancestor

2011-07-28 Thread sunny agrawal
Solution in the link is for BST, not for BT On Thu, Jul 28, 2011 at 3:15 PM, kavitha nk kavithan...@gmail.com wrote: http://geeksforgeeks.org/?p=1029 follow the link fa one more soln.. //BE COOL// kavi -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Least Common Ancestor

2011-07-28 Thread kavitha nk
oh 5n sry...how to get practiced wit algo???help me //BE COOL// kavi -- 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

Re: [algogeeks] Least Common Ancestor

2011-07-27 Thread ankit sambyal
First make an iterative DFS function which stores node pointers on the stack instead of node values and break as soon as the node value of the node pointer on the top of the stack reaches a specified value. void iterative_dfs(Node *root,int n1); Let n1 and n2 be the values whose LCA is to be

Re: [algogeeks] Least Common Ancestor

2011-07-27 Thread Rajeev Kumar
@$iva : check this link : http://www.technicalypto.com/search/label/binary%20tree On Wed, Jul 27, 2011 at 11:08 AM, sivaviknesh s sivavikne...@gmail.comwrote: How to find Least Common Ancestor of a BINARY TREE without using PARENT POINTERS ? give algo / ideas plz ?? -- Regards, $iva