On 3/21/13 5:02 PM, Avinash wrote:
Given a STL map, say map 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, fin
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 furth
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
algogeeks+u
Solution in the link is for BST, not for BT
On Thu, Jul 28, 2011 at 3:15 PM, kavitha nk 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
> "Algorithm Geeks" gr
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
@$iva : check this link :
http://www.technicalypto.com/search/label/binary%20tree
On Wed, Jul 27, 2011 at 11:08 AM, sivaviknesh s wrote:
> How to find Least Common Ancestor of a BINARY TREE without using PARENT
> POINTERS ?
>
> give algo / ideas plz ??
>
> --
> Regards,
> $iva
>
> --
> You r
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 found