do the inorder traversal of the bst ...this gives the sorted array......
from that use

int i=0,j=length(array)
while(i<j)
{
if(array[i]+array[j]>sum)
--j;
else if(array[i]+array[j]<sum)
++i;
else if((array[i]+array[j])==sum)
return i,j
else
++i,--j;
}


On Fri, Aug 6, 2010 at 3:10 PM, Chonku <[email protected]> wrote:

> Two inorders would achieve the same thing without using an array. One
> pointer running inorder with LDR and other pointer running inorder with RDL.
> Compare the sum at the two nodes and then adjust them accordingly.
>
> On Fri, Aug 6, 2010 at 2:11 PM, Manjunath Manohar <
> [email protected]> wrote:
>
>> the solution elegant..but is there any on the fly method by just
>> exploiting the BST property....by using left and right pointers
>>
>> --
>>  You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<algogeeks%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
yezhu malai vaasa venkataramana Govinda Govinda

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to