@sunny agarwal : i dont think, it is O(lgn) its not a BST and further
u need to check for existence of
y in the path from lca to x or lca to z., so it l be O(n)..

On Jun 10, 1:57 pm, sunny agrawal <sunny816.i...@gmail.com> wrote:
> find common Ancestor of both. see if y lies on path from x or z to this
> ancestor
> O(lgn)
>
> On Fri, Jun 10, 2011 at 1:20 PM, aanchal goyal 
> <goyal.aanch...@gmail.com>wrote:
>
>
>
>
>
>
>
>
>
> > There is a binary tree(Not a BST) in which you are given three nodes
> > x,y,z .Write a function which finds whether y lies in the path b/w x
> > and z.
>
> > --
> > Regards,*
> > Aanchal Goyal*.
>
> >  --
> > 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, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to