Consider an array data of n numerical values in sorted order and a list of numerical target values. Your goal is to compute the smallest range of array indices that contains all of the target values. If a target value is smaller than data[0], the range should start with -1. If a target value is larger than data[n - 1], the range should end with n.
For example, given the array in Figure 3 and the target values (8, 2, 9, 17), the range is -1 to 5.
a. Devise an efficient algorithm that solves this problem.
b. If you have n data values in the array and m target values in the list, what is the Big Oh performance of your algorithm?
c. Implement and test your algorithm.
FIGURE 3 An array for Project 4
![]()
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.