Hey I'm looking for a solution to the belowe question. Any recommendations on how to write this algorithm???
Thanks:
You are given a sequence s of numbers, in increasing order, for example:
s = 2, 5, 7, 9, 13, 15.
You are also given a number n, say n = 16. You have to try to find two numbers x and y from s, such that x+y = n, if such numbers exist. In this example, you could take x = 7 and y = 9.
However, you must do so as efficiently as possible: you must not perform more additions than the number of elements in s. Describe an algorithm to do this.