Question: and determine if that number exists in the array or not. But this time, start by SORTING your input list. After a sort, the list

and determine if that number exists in the array or not. But this time, start by SORTING your input list. After a sort, the list in problem 1 is as follows:
]
[49,50,52,52,59,71,81,82,88,89,89,93,96,97
Approach:
Implement a method called findC(x,A,i,j), where x is the number we are looking for in array A, the first index of the array is i and the last index is j. We want to determine whether x exists in A anywhere between index i and index j. Your first call to this method will therefore look like this: ength-1).
In the body of your function, compare x with the item that is in the middle of the array, as you did before. As before, call the middle of index of the array mid. But this time, if xa[mid], recursively call your function to search ONLY the first half of the array, i.e. between index i and mid. If x>a[mid], recursively call your function to search ONLY the second half of the array, i.e. from mid +1 to j.
If you call f indc (x,A,i,j when i is equal to j, note that there is only one element in the range. In this case, compare x with a [i](or a [j]). If they are equal, return true, otherwise return false. If you call the function when xA(x,A,i,j)A,x,ij1,6,10,14,77,82,100x1,6,10,14,77,82,10077,82,100
 and determine if that number exists in the array or not.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!