Instead of using an array...we can do this by converting the BST into a
doubly linked list...but this will definitely modify the BST..


On Mon, Jun 27, 2011 at 3:01 PM, varun pahwa <[email protected]>wrote:

> @ankit: no need to use hash table for that.
> simply run two pointers one from 0 and second from n - 1.
>
> On Mon, Jun 27, 2011 at 2:51 PM, ankit sambyal <[email protected]>wrote:
>
>> @Bharath : Cud u plz explain how r u searching the elements in O(n) time?
>> Because if we use binary search, it will have O(n*log n )  worst case
>> time complexity. One way in which I think it cud be made O(n) is that
>> we can use a hash table, with a good hash function apart frm the
>> array. And then for each element 'm' in the array, we cud search if
>> there is an element (sum - m) in O(1) time by using hash table. Still
>> we can't assure O(n) time complexity. Because coming up with a good
>> hash function is not easy. Again, hash table takes more space....
>>
>>
>>
>>
>> On Mon, Jun 27, 2011 at 1:40 AM, Nishant Mittal
>> <[email protected]> wrote:
>> > do inorder traversal of tree and store values in an array.
>> > Now find pairs by applying binary search on array..
>> >
>> > On 6/27/11, manish kapur <[email protected]> wrote:
>> >>
>> >>
>> >> --
>> >> 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.
>> >>
>> >>
>> >
>> > --
>> > 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.
>> >
>> >
>>
>> --
>>  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.
>>
>>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112 ,08011820777
> Official Email :: [email protected]
> Another Email :: [email protected]
>
> People who fail to plan are those who plan to fail.
>
> --
>  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.
>



-- 
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=100000655377926 *

-- 
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