The input is a set S containing n real numbers and one real numb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijayboss
    New Member
    • Feb 2010
    • 1

    The input is a set S containing n real numbers and one real numb

    Consider the problem:The input is a set S containing n real numbers and one real number x.Design an algorithm to determine whether there are two elements of S whose sum is exactly x.The alogorithm should run O(nlogn).Suppos e now that the set S is given in sorted order.Design an algorithm to solve the problem in time O(n).
    could someone send me the algorithm for the above questions
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Trying all possibilities of combinations will result in a n^2 time.

    Try sorting the set first.

    Comment

    Working...