take two stacks of O(logn) space use one to traverse as left - > root->
right (inorder) and other as right->root-> left(reverse inorder) like

while (true){

 a=top(s1);
b=top(s2);
if(a+b==sum ) break;
if(a+b <sum){
  pop(s1);
}else if(a+b > sum) pop(s2);
}

if(s1 && s2 are empty) no solution
else result = top(s1) and top(s2);

On Tue, Mar 5, 2013 at 1:24 PM, marti <[email protected]> wrote:

> Given a value , print two nodes that sum to the value in a BST and normal
> tree.. time:O(n), space O(logn).
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards,
Sourabh Kumar Jain
+91-8971547841

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to