can be done in O(n) with hashing

On Wed, Aug 31, 2011 at 11:09 AM, Ankit Minglani
<[email protected]>wrote:

> one method can be :
>
> Let T = the sum
>
> for(i=0;i<n;i++)
> {
>    temp=T- x[i];
>    // perform a binary search on array[ i+1..... n-1] to find temp it if
> does then just output.
> }
>
>
>
>
>
>
>
>
>
>
>
>
> On Wed, Aug 31, 2011 at 11:04 AM, bharatkumar bagana <
> [email protected]> wrote:
>
>> Its brute force method.....O(n^2) algo...
>> for(int i=0;i<n;i++)
>>   for(int j=i+1;j<n;j++)
>>   {
>>      if(x==A[i]+A[j])
>>       { print A[i],A[j];     break;}
>>
>>   }
>>
>> On Wed, Aug 31, 2011 at 1:15 AM, Reynald <[email protected]> wrote:
>>
>>> For example, in array, say,
>>> <8, 9, 2, 4, 6, 2, 3>
>>>
>>> Input 5, output 2 and 3.
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>>
>> **Please do not print this e-mail until urgent requirement. Go Green!!
>> Save Papers <=> Save Trees
>> *BharatKumar Bagana*
>> **http://www.google.com/profiles/bagana.bharatkumar<http://www.google.com/profiles/bagana.bharatkumar>
>> *
>> Mobile +91 8056127652*
>> <[email protected]>
>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> The more you sweat in the field, the less you bleed in war."
>
> Ankit Minglani
> NITK Surathkal
>
>  --
> 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.

Reply via email to