Question: (6) (14 pts) Suppose we are given two sorted arrays (nondecreasing from index 1 to index n ) X[1]X[n] and Y[1]Y[n] of integers. Problem is

(6) (14 pts) Suppose we are given two sorted arrays (nondecreasing from index 1 to index n ) X[1]X[n] and Y[1]Y[n] of integers. Problem is to design an algorithm that determines if there is a number p in X and a number q in Y such that p+q is zero. If such numbers exist, the algorithm returns true; otherwise, it returns false. (a) Consider the following algorithm for the problem: for i=1 to n if (binary search in Y[1]Y[n] finds X[i]) return (true); return (false); Analyze the algorithm to determine the complexity of the algorithm
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
