@rashmi..
just sort the set in O(nlogn)....
then use two pointers ... one from first end and another from second
end....given below...in O(n)..
i=0;
j=n-1;
while(i<j)
{
   if((a[i]+a[j])==x)
    { printf("%d%d",a[i],a[j]);
       break;}
    if((a[i]+a[j])>x)
       j--;
    else
       i++;
}

do it with example...

running time...O(nlogn)...
With regards,

Praveen Raj
DCE-IT 3rd yr
9999735993
praveen0...@gmail.com

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

Reply via email to