Question: 1. (Adapted from Exercise 2.3-7 in the textbook) Write pseudocode for a (n Ig n-time algorithm that, given an array A of n integers and
1. (Adapted from Exercise 2.3-7 in the textbook) Write pseudocode for a (n Ig n-time algorithm that, given an array A of n integers and another integerx, determines whether or not there exist two elements in A whose sum is exactly x. Explain informally why your algorithm is (n lg n)-time. You may use calls to the Merge-Sort algorithm in the textbook as part of your pseudocode. (Hint: Let p be the smallest element of A, r be the largest element of A, and z be any other element. Ifp+
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
