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 is as follows:
Approach:
Implement a method called findC where is the number we are looking for in array A the first index of the array is i and the last index is We want to determine whether exists in A anywhere between index i and index Your first call to this method will therefore look like this: ength
In the body of your function, compare 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 recursively call your function to search ONLY the first half of the array, ie between index i and mid. If recursively call your function to search ONLY the second half of the array, ie from mid to
If you call indc when is equal to note that there is only one element in the range. In this case, compare with a ior a j If they are equal, return true, otherwise return false. If you call the function when
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
