>For those who know about asymptotic behavior:
>
>
Given an array of increasing numbers and a number X, create a linear algorithm that finds whether the array contains two numbers that sum to X (and those two numbers if they exist).>
>Daniel
Here is one solution (I think) with only one loop and I am also using the < pre > tags for the first time ;)
for i = 1 to alen(myarray)
if ascan(myarray, X - myarray(i)) > 0
return myarray(i), myarray(ascan(myarray, X - myarray(i)))
endi
next i
Einar
Semper ubi sub ubi.