Design an *O(n)*-time algorithm that, given a real number *x * and a sorted
array *S* of *n * numbers, determines whether or not there exist two
elements in *S* whose sum is exactly *x *.

since array is already sorted, doing binary search for x-S[i] ,for each
element indexed at i will give a nlogn solution. How to get O(n) solution??

-- 
Harshal Choudhary

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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