Find two integers in a set that sum to given value


Question:

Find two integers in a set that sum to given value.

Suppose you are given a set P of integers and another integer x. We wish to use a O(n*lg n) algorithm to decide whether there are 2 integers in P whose sum equals to x. Show your algorithm. You can use pseudo code or verbose description to explain your algorithm.

If you need to use any well known standard algorithm in your solution, you need not give details of that, just mention how that is helping you in devising solution for the given problem.

Note that there is no restriction on integers in set P and integer x, that is, we are not restricting ourselves to positive or negative integers.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Find two integers in a set that sum to given value
Reference No:- TGS01936550

Now Priced at $20 (50% Discount)

Recommended (98%)

Rated (4.3/5)