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