Given a set of S containing n real numbers, and a real number x. We seek an algorithm to determine whether two elements of S exist whose sum is exactly x.
(a) Assume that S is unsorted. Give an O(n log n) algorithm for the problem.
(b) Assume that S is sorted. Give an O(n) algorithm for the problem.